Jump to content

Recommended Posts

Posted

hi

for change the keyboard to ENG i test the all ways like:

#include <WinAPISys.au3>
_WinAPI_LoadKeyboardLayout ( $iLanguage [, $iFlag = 0] )

and

DllCall("user32.dll", "long", "LoadKeyboardLayout", "str", 0x0409, "int", 0)

also

DllCall("user32.dll", "long", "LoadKeyboardLayout", "str", 00000409, "int", 0)

 

but any code not work

But a piece of code written in NSIS well this performs:

that code (NSIS code) is:

System::Call "user32::LoadKeyboardLayout(t '00000409',i 0x00000001)"

now i how can write like that in Autoit?

Posted (edited)

@r2du-soft
This code seems to work:

#include <WinAPISys.au3>

Global $iLayout = 0x0409

If _WinAPI_LoadKeyboardLayout($iLayout, $KLF_ACTIVATE) <> 0 Then
    ConsoleWrite("_WinAPI_LoadKeyboardLayout OK!" & @CRLF)
    Sleep(5000) ; So you can see if the language is present in the language box 
    ConsoleWrite("_WinAPI_UnloadKeyboardLayout = " & _WinAPI_UnloadKeyboardLayout($iLayout) & @CRLF)
EndIf

Did you check in the language box if the language desired is present? :)

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Posted

again not work...

yes, i see the english language in keyboard layout and i can write english

really i dont what is problem!

if is possible you compile you'r code and attach exe in post till i test that,Perhaps my compiler has problem! 

 

Posted
2 minutes ago, FrancescoDiMuro said:

The above code doesn't work for you?

no not work

my windows informatuion:

windows 10 x64

version 1909 OS Build 18.363.778

 

I am surprised by this autoit script not work but nsis script worked and can change the keyboard

i need to do this

😔

 

  • Developers
Posted
5 hours ago, r2du-soft said:

hi

for change the keyboard to ENG i test the all ways like:

#include <WinAPISys.au3>
_WinAPI_LoadKeyboardLayout ( $iLanguage [, $iFlag = 0] )

and

... and how exactly did your script look where you tested with?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

This has always been working fine, to change the system tray keyboard language :

Local $SPI_SETLANGTOGGLE = 0x005B
;Sets the hot key set for switching between input languages. The uiParam and pvParam parameters are not used.
;The value sets the shortcut keys in the keyboard property sheets by reading the registry again.
;The registry must be set before this flag is used. the path in the registry is HKEY_CURRENT_USER\Keyboard Layout\Toggle
;Valid values are "1" = ALT+SHIFT, "2" = CTRL+SHIFT, and "3" = none.

 ConsoleWrite (_WinAPI_SystemParametersInfo ($SPI_SETLANGTOGGLE, 1) & @CRLF)
 Send ("{ALTDOWN}")
 Send ("{LSHIFT}")
 Send ("{ALTUP}")

Works for Windows 7 and Windows 10 

Posted
17 hours ago, Jos said:

... and how exactly did your script look where you tested with?

 Jos

i test all execute exe file in my windows 10 and two windows vps server: windows vps server 2012 r2

Posted (edited)
15 hours ago, Nine said:

This has always been working fine, to change the system tray keyboard language :

Local $SPI_SETLANGTOGGLE = 0x005B
;Sets the hot key set for switching between input languages. The uiParam and pvParam parameters are not used.
;The value sets the shortcut keys in the keyboard property sheets by reading the registry again.
;The registry must be set before this flag is used. the path in the registry is HKEY_CURRENT_USER\Keyboard Layout\Toggle
;Valid values are "1" = ALT+SHIFT, "2" = CTRL+SHIFT, and "3" = none.

 ConsoleWrite (_WinAPI_SystemParametersInfo ($SPI_SETLANGTOGGLE, 1) & @CRLF)
 Send ("{ALTDOWN}")
 Send ("{LSHIFT}")
 Send ("{ALTUP}")

Works for Windows 7 and Windows 10 

hum! thats nice 

but its a standard method?

What if the user has 3 languages,How do I tell?

So far I've tested realized that also _WinAPI_GetKeyboardLayout not work!

look at this code:

;-----------------------------------------------------
;#Compiler options
        #RequireAdmin
        #NoTrayIcon
;-----------------------------------------------------

;-----------------------------------------------------
;#pragma options
        #pragma compile(Out, KeyboardLayoutTester.exe)
        #pragma compile(ExecLevel, highestavailable)
        #pragma compile(UPX, False)
        #pragma compile(Compression, 9)
        #pragma compile(ProductVersion, 1.0)
        #pragma compile(FileVersion, 1.0.0.0, 1.0.000.100)
;-----------------------------------------------------

;-----------------------------------------------------
;#includes
        #include-once
        #include <GuiConstants.au3>
        #include <MsgBoxConstants.au3>
        #include <WinAPIError.au3>
        #include <WinAPISys.au3>
;-----------------------------------------------------

;-----------------------------------------------------
;#Variable
        Local $hWnd
        Local $textBox_LicenseKey
        Local $Button_Persian
        Local $Button_English
        Local $Button_Exit
        Local $i_KeyboardLayout
;-----------------------------------------------------


;-----------------------------------------------------
;#Main
        $GUI_HWNDPARENT = GUICreate("KeyboardLayout Tester", 338, 205, -1, -1, $WS_POPUPWINDOW)
        GUIRegisterMsg($WM_NCHITTEST, "MoveGUI_Set") ;Move GUI from Click and Drag Drop
        $textBox_LicenseKey = GUICtrlCreateInput("", 20, 50, 288, 20, BitOR($ES_CENTER, $ES_MULTILINE))
        $Button_Persian = GUICtrlCreateButton("Persian", 20, 90, 116, 38)
        $Button_English = GUICtrlCreateButton("English", 192, 90, 116, 38)
        $Button_Exit = GUICtrlCreateButton("Exit", 104, 145, 116, 38)
        GUISetState()
;-----------------------------------------------------


;-----------------------------------------------------
Func MoveGUI_Set($hWnd, $iMsg, $iwParam, $ilParam)
  if $hWnd = $GUI_HWNDPARENT and $iMsg = $WM_NCHITTEST then Return $HTCAPTION
EndFunc
;-----------------------------------------------------

;-----------------------------------------------------
While 1
    $iMsg_Main = GUIGetMsg()
    Select
    
    Case $iMsg_Main = $GUI_EVENT_CLOSE OR $iMsg_Main = $Button_Exit
        GUIDelete()
        Exit
        
    Case $iMsg_Main = $Button_Persian
        $i_KeyboardLayout = 0x0429
        _WinAPI_SetKeyboardLayout($GUI_HWNDPARENT, $i_KeyboardLayout)
        _WinAPI_UnloadKeyboardLayout($i_KeyboardLayout)
        _WinAPI_LoadKeyboardLayout($i_KeyboardLayout)
        GUICtrlSetState($textBox_LicenseKey, $GUI_FOCUS)
        MsgBox(0,"Return KeyboardLayout", _WinAPI_GetKeyboardLayout($GUI_HWNDPARENT))
        
    Case $iMsg_Main = $Button_English
        $i_KeyboardLayout = 0x0409
        _WinAPI_SetKeyboardLayout($GUI_HWNDPARENT, $i_KeyboardLayout)
        _WinAPI_UnloadKeyboardLayout($i_KeyboardLayout)
        _WinAPI_LoadKeyboardLayout($i_KeyboardLayout)
        GUICtrlSetState($textBox_LicenseKey, $GUI_FOCUS)
        MsgBox(0,"Return KeyboardLayout", _WinAPI_GetKeyboardLayout($GUI_HWNDPARENT))
        
    EndSelect
WEnd
;-----------------------------------------------------

if i click on Persian Button or click on English Button Anyway i display message: 0x04090409

What do you think about this?

also i test above code in windows 10 and windows vps server 2012 r2 but not worked and the result was the same as before

2020-04-23_9-35-50.png

2020-04-23_9-35-33.png

2020-04-23_9-35-50.jpg

2020-04-23_9-35-33.jpg

Edited by r2du-soft
Posted

Problem Fixed

 

;-----------------------------------------------------
;#Compiler options
        #RequireAdmin
        #NoTrayIcon
;-----------------------------------------------------

;-----------------------------------------------------
;#pragma options
        #pragma compile(Out, KeyboardLayoutTester.exe)
        #pragma compile(ExecLevel, highestavailable)
        #pragma compile(UPX, False)
        #pragma compile(Compression, 9)
        #pragma compile(ProductVersion, 1.0)
        #pragma compile(FileVersion, 1.0.0.0, 1.0.000.100)
;-----------------------------------------------------

;-----------------------------------------------------
;#includes
        #include-once
        #include <GuiConstants.au3>
        #include <MsgBoxConstants.au3>
        #include <WinAPIError.au3>
        #include <WinAPISys.au3>
;-----------------------------------------------------

;-----------------------------------------------------
;#Variable
        Local $hWnd
        Local $textBox_LicenseKey
        Local $Button_Persian
        Local $Button_English
        Local $Button_Exit
        Local $i_KeyboardLayout
;-----------------------------------------------------


;-----------------------------------------------------
;#Main
        $GUI_HWNDPARENT = GUICreate("KeyboardLayout Tester", 338, 205, -1, -1, $WS_POPUPWINDOW)
        GUIRegisterMsg($WM_NCHITTEST, "MoveGUI_Set") ;Move GUI from Click and Drag Drop
        $textBox_LicenseKey = GUICtrlCreateInput("", 20, 50, 288, 20, BitOR($ES_CENTER, $ES_MULTILINE))
        $Button_Persian = GUICtrlCreateButton("Persian", 20, 90, 116, 38)
        $Button_English = GUICtrlCreateButton("English", 192, 90, 116, 38)
        $Button_Exit = GUICtrlCreateButton("Exit", 104, 145, 116, 38)
        GUISetState()
;-----------------------------------------------------


;-----------------------------------------------------
Func MoveGUI_Set($hWnd, $iMsg, $iwParam, $ilParam)
  if $hWnd = $GUI_HWNDPARENT and $iMsg = $WM_NCHITTEST then Return $HTCAPTION
EndFunc
;-----------------------------------------------------

;-----------------------------------------------------
While 1
    $iMsg_Main = GUIGetMsg()
    Select
    
    Case $iMsg_Main = $GUI_EVENT_CLOSE OR $iMsg_Main = $Button_Exit
        GUIDelete()
        Exit
        
    Case $iMsg_Main = $Button_Persian
        $i_KeyboardLayout = 0x0429
        _WinAPI_SetKeyboardLayout($GUI_HWNDPARENT, $i_KeyboardLayout)
        _WinAPI_UnloadKeyboardLayout($i_KeyboardLayout)
        _WinAPI_LoadKeyboardLayout($i_KeyboardLayout)
        _WinAPI_ActivateKeyboardLayout($i_KeyboardLayout)
        GUICtrlSetState($textBox_LicenseKey, $GUI_FOCUS)
        MsgBox(0,"Return KeyboardLayout", _WinAPI_GetKeyboardLayout($GUI_HWNDPARENT))
        
    Case $iMsg_Main = $Button_English
        $i_KeyboardLayout = 0x0409
        _WinAPI_SetKeyboardLayout($GUI_HWNDPARENT, $i_KeyboardLayout)
        _WinAPI_UnloadKeyboardLayout($i_KeyboardLayout)
        _WinAPI_LoadKeyboardLayout($i_KeyboardLayout)
        _WinAPI_ActivateKeyboardLayout($i_KeyboardLayout)
        GUICtrlSetState($textBox_LicenseKey, $GUI_FOCUS)
        MsgBox(0,"Return KeyboardLayout", _WinAPI_GetKeyboardLayout($GUI_HWNDPARENT))
        
    EndSelect
WEnd
;-----------------------------------------------------

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...