IlanMS Posted July 16, 2021 Share Posted July 16, 2021 I have (mostly) used copy paste to switch between 2 keyboard layouts: $hWnd= WinGetHandle("[active]") if _GetKeyboardLayout($hWnd = "0000040D") then _SetKeyboardLayout("00000409", $hWnd) else _SetKeyboardLayout("0000040D", $hWnd) endif Func _GetKeyboardLayout($hWnd) Local $ret = DllCall("user32.dll", "long", "GetWindowThreadProcessId", "hwnd", $hWnd, "ptr", 0) $ret = DllCall("user32.dll", "long", "GetKeyboardLayout", "long", $ret[0]) Return "0000" & Hex($ret[0], 4) EndFunc Func _SetKeyboardLayout($sLayoutID, $hWnd) Local $WM_INPUTLANGCHANGEREQUEST = 0x50 Local $ret = DllCall("user32.dll", "long", "LoadKeyboardLayout", "str", $sLayoutID, "int", 0) DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $hWnd, _ "int", $WM_INPUTLANGCHANGEREQUEST, _ "int", 1, _ "int", $ret[0]) EndFunc Problem is the "else" statement never get executed. I switched the "if" statements and always the 1st is executed, never the second, "else" statement. I have tested previously the _GetKeyboardLayout function, and it worked as it should. btw, How do I insert text in code format? Link to comment Share on other sites More sharing options...
Developers Solution Jos Posted July 16, 2021 Developers Solution Share Posted July 16, 2021 Your if is wrong. The compare is inside of the function. 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. Link to comment Share on other sites More sharing options...
JockoDundee Posted July 16, 2021 Share Posted July 16, 2021 47 minutes ago, IlanMS said: btw, How do I insert text in code format? Use the <> button. Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
IlanMS Posted July 16, 2021 Author Share Posted July 16, 2021 DOH! Link to comment Share on other sites More sharing options...
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