J0ker Posted December 26, 2006 Share Posted December 26, 2006 (edited) How to set a hotkey to work only the first time it pressed? I have a hotkey that start my script and I want it to work only one time. Is there any way to do that? HotKeySet("{ENTER}", "Begin") ; Run the script when ENTER is pressed Edited December 26, 2006 by J0ker Link to comment Share on other sites More sharing options...
_Kurt Posted December 26, 2006 Share Posted December 26, 2006 (edited) Hmm, well I'm not sure if this is what you want, but this works:;UNTESTED but probably works #include <Misc.au3> While 1 If _IsPressed("number") Then ; Look up _IsPressed in the UDF helpfile for the correct "number" ;do whatever you want ExitLoop EndIf WEnd ;(.. the rest of your script)This works, but it may not be what you want.Good Luck with your script!KurtEDIT: the script will loop until (hotkey) is pressed, after it is, you do whatever and exit the loop and finish the rest of your script Edited December 26, 2006 by _Kurt Awaiting Diablo III.. Link to comment Share on other sites More sharing options...
J0ker Posted December 26, 2006 Author Share Posted December 26, 2006 (edited) It's not exactly what I want. I dont want the script to loop until the key is pressed but to kinda block this hotkey or disable it when it pressed.The Hotkey ENTER start my script so there's no reason why it should be used again during the script. It's why I want to disable it so if accidently someone press ENTER again when the script is running, nothing will happen.Something like that: HotKeySet("{ENTER}", "Begin") ; Run the script when ENTER is pressed Func Begin() Disable Hotkey "Enter" ;blablabla EndFunc Edited December 26, 2006 by J0ker Link to comment Share on other sites More sharing options...
Jabberwock Posted December 26, 2006 Share Posted December 26, 2006 $hotkey = "{F10}" $hotkeyset = 0 While 1 test() Wend Func test() If $hotkeyset = 0 then HotKeySet($hotkey, "somefunc") Elseif $hotkeyset = 1 then HotKeySet($hotkey) EndIf EndFunc Func somefunc() $hotkeyset = 1 MsgBox(0, "Test", "Works?") EndFunc Link to comment Share on other sites More sharing options...
Outshynd Posted December 26, 2006 Share Posted December 26, 2006 HotKeySet("{ENTER}", "Begin") Func Begin() HotKeySet("{ENTER}") ;blah blah blah EndFunc Link to comment Share on other sites More sharing options...
Jabberwock Posted December 26, 2006 Share Posted December 26, 2006 yeah, seems i was over thinking that one, you simplified mine =P Link to comment Share on other sites More sharing options...
J0ker Posted December 26, 2006 Author Share Posted December 26, 2006 HotKeySet("{ENTER}", "Begin") Func Begin() HotKeySet("{ENTER}") ;blah blah blah EndFunc Wow Amazing, so simple ! Thanks alot Outshynd Link to comment Share on other sites More sharing options...
Outshynd Posted December 27, 2006 Share Posted December 27, 2006 You're welcome 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