#include <Misc.au3>
_WinAPI_LoadKeyboardLayoutEx()
HotKeySet('x', '_MyFunc')
HotKeySet('{Esc}', '_Exit')
ToolTip('Wait for pressing "x"', 0, 0)
While 1
Sleep(100)
WEnd
Func _Exit()
Exit
EndFunc ;==>_Exit
Func _MyFunc()
HotKeySet('x')
ToolTip('Key "x" is pressing now', 0, 0);действие при нажатии
Do
Sleep(10)
Until Not _IsPressed('58')
ToolTip('Key "x" no press', 0, 0);действие при отпускании
HotKeySet('x', '_MyFunc')
EndFunc ;==>_MyFunc
Func _WinAPI_LoadKeyboardLayoutEx($sLayoutID = 0x0409, $hWnd = 0)
Local Const $WM_INPUTLANGCHANGEREQUEST = 0x50
Local $aRet = DllCall("user32.dll", "long", "LoadKeyboardLayoutW", "wstr", Hex($sLayoutID, 8), "int", 0)
If Not @error And $aRet[0] Then
If $hWnd = 0 Then
$hWnd = WinGetHandle(AutoItWinGetTitle())
EndIf
DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $hWnd, "int", $WM_INPUTLANGCHANGEREQUEST, "int", 1, "int", $aRet[0])
Return 1
EndIf
Return SetError(1)
EndFunc