#include <GuiConstants.au3>
HotKeySet("{ENTER}", "catchguikey")
$gui = GuiCreate("Hotkey Test")
GuiCtrlCreateLabel("Press Enter", 0, 0)
GuiSetState()
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
Func catchguikey()
Local $opt = Opt("WinTitleMatchMode", 4)
If WinGetHandle("active") = $gui Then
If @HotKeyPressed = "{ENTER}" Then
;Do something here
ToolTip("Key Pressed")
Sleep(1000)
ToolTip("")
EndIf
Else
HotKeySet(@HotKeyPressed)
Send(@HotKeyPressed)
HotKeySet(@HotKeyPressed, "catchguikey")
EndIf
Opt("WinTitleMatchMode", $opt)
EndFunc
|