r2du-soft Posted April 22, 2020 Posted April 22, 2020 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?
FrancescoDiMuro Posted April 22, 2020 Posted April 22, 2020 (edited) @r2du-soft What is the return value of the function, and, eventually, what is the value of_WinAPI_GetLastError() after the function call? Edited April 22, 2020 by FrancescoDiMuro r2du-soft 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
r2du-soft Posted April 22, 2020 Author Posted April 22, 2020 12 minutes ago, FrancescoDiMuro said: @r2du-soft What is the return value of the function, and, eventually, what is the value of_WinAPI_GetLastError() after the function call? hi i test _WinAPI_LoadKeyboardLayout(0x0409) MsgBox(0,"Return KeyboardLayout Error", _WinAPI_GetLastError()) return value is 0
FrancescoDiMuro Posted April 22, 2020 Posted April 22, 2020 (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 April 22, 2020 by FrancescoDiMuro r2du-soft 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
r2du-soft Posted April 22, 2020 Author Posted April 22, 2020 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!
FrancescoDiMuro Posted April 22, 2020 Posted April 22, 2020 2 minutes ago, r2du-soft said: again not work... The above code doesn't work for you? r2du-soft 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
r2du-soft Posted April 22, 2020 Author Posted April 22, 2020 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 Jos Posted April 22, 2020 Developers Posted April 22, 2020 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.
Nine Posted April 22, 2020 Posted April 22, 2020 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 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
r2du-soft Posted April 23, 2020 Author Posted April 23, 2020 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
r2du-soft Posted April 23, 2020 Author Posted April 23, 2020 (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: expandcollapse popup;----------------------------------------------------- ;#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 Edited April 23, 2020 by r2du-soft
r2du-soft Posted April 23, 2020 Author Posted April 23, 2020 Problem Fixed expandcollapse popup;----------------------------------------------------- ;#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 ;-----------------------------------------------------
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now