Andreik Posted August 28, 2008 Posted August 28, 2008 Why I cannot use enter key if I use it as hotkey in my script? For example if I run this script and then I select a file from my desktop and I press ENTER, the file is not open. HotKeySet("{ENTER}","Message") While 1 Sleep(20) WEnd Func Message() MsgBox(0,"","MESSAGE") EndFunc Can I solve this inconvenient someway?
rasim Posted August 28, 2008 Posted August 28, 2008 Why I cannot use enter key if I use it as hotkey in my script? For example if I run this script and then I select a file from my desktop and I press ENTER, the file is not open. HotKeySet("{ENTER}","Message") While 1 Sleep(20) WEnd Func Message() MsgBox(0,"","MESSAGE") EndFunc Can I solve this inconvenient someway? Help When you set a hotkey, AutoIt captures the key-press and does not pass it on to the active application
Andreik Posted August 28, 2008 Author Posted August 28, 2008 Thanks rasim! I read now in help file and I saw that the Lock keys isn't captures. Is any way to create exceptions for other keys?
rasim Posted August 28, 2008 Posted August 28, 2008 AndreikSolution:#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> ;HotKeySet("{ENTER}","Message") Global $Active = False $hGUI = GUICreate("My GUI", 300, 200) GUIRegisterMsg($WM_ACTIVATE, "WM_ACTIVATE") GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func WM_ACTIVATE($hWnd, $Msg, $wParam, $lParam) $Active = Not $Active If $Active Then HotKeySet("{ENTER}","Message") Else HotKeySet("{ENTER}") EndIf Return $GUI_RUNDEFMSG EndFunc Func Message() MsgBox(0,"","MESSAGE") EndFunc
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