Search the Community
Showing results for tags 'Keyboard Layout'.
-
Hello everyone, I can't get _WinAPI_SetKeyboardLayout to change the keyboard layout for autoit GUI windows (works fine for other windows), but I can get the current keyboard layout _WinAPI_GetKeyboardLayout .. am I missing something? $GUI = GUICreate('test') GUICtrlCreateEdit('', 10, 10) GUISetState() Sleep(1000) $KB = _WinAPI_SetKeyboardLayout("00000401", $GUI) Sleep(1000) MsgBox(0, $KB, _WinAPI_GetKeyboardLayout($GUI)) Func _WinAPI_GetKeyboardLayout($hWnd) Local $Ret = DllCall('user32.dll', 'long', 'GetWindowThreadProcessId', 'hwnd', $hWnd, 'ptr', 0) If (@error) Or ($Ret[0] = 0) Then Return SetError(1, 0, 0) EndIf $Ret = DllCall('user32.dll', 'long', 'GetKeyboardLayout', 'long', $Ret[0]) If (@error) Or ($Ret[0] = 0) Then Return SetError(1, 0, 0) EndIf Return '0000' & Hex($Ret[0], 4) EndFunc Func _WinAPI_SetKeyboardLayout($sLayout, $hWnd) If Not WinExists($hWnd) Then Return SetError(1, 0, 0) EndIf Local $Ret = DllCall('user32.dll', 'long', 'LoadKeyboardLayout', 'str', StringFormat('%08s', StringStripWS($sLayout, 8)), 'int', 0) If (@error) Or ($Ret[0] = 0) Then Return SetError(1, 0, 0) EndIf DllCall('user32.dll', 'ptr', 'SendMessage', 'hwnd', $hWnd, 'int', 0x0050, 'int', 1, 'int', $Ret[0]) Return SetError(0, 0, 1) EndFunc
- 3 replies
-
- Keyboard Layout
- WinAPI
-
(and 1 more)
Tagged with: