Aapjuh Posted October 19, 2012 Share Posted October 19, 2012 Hi all, Situation: Im trying to make a gui move to the right with HotKeySet("{d}", "_Right") which goes to func _Right(). The _Right() func does a sleep(1000) and then a winmove to currentcoord + 5 Problem: If i press 'd' once, it waits 1sec and then moves the gui by 5. if i press 'd' 3x in a row, it waits 1sec then moves the gui by 15 what i want is if i press 'd' 3x in a row it waits 1sec moves 5 waits 1sec moves 5 etc etc. is there a delay option for hotkeyset? or what am i doing wrong? thnx in advance, Aapjuh ;gui stuff etc not rly needed; HotKeySet("{d}", "_Right") Func _Right() Sleep(1000) $BoxPos1 = $BoxPos1 + 5 Winmove($Box, "", $BoxPos1, $BoxPos2) EndFunc Link to comment Share on other sites More sharing options...
BrewManNH Posted October 19, 2012 Share Posted October 19, 2012 If you want it so that the hotkey isn't active when you're script is sleeping, you need to unregister the hotkey as you enter the function and then reregister it as you leave it. This way the script won't pay any attention to your hotkey presses. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Aapjuh Posted October 19, 2012 Author Share Posted October 19, 2012 If you want it so that the hotkey isn't active when you're script is sleeping, you need to unregister the hotkey as you enter the function and then reregister it as you leave it. This way the script won't pay any attention to your hotkey presses. thnx for the awesome fast reply it worked! thnx alot added: HotKeySet("{d}", "_Nothing") ;gui stuff etc not rly needed; HotKeySet("{d}", "_Right") Func _Right() HotKeySet("{d}", "_Nothing") Sleep(1000) $BoxPos1 = $BoxPos1 + 5 Winmove($Box, "", $BoxPos1, $BoxPos2) HotKeySet("{d}", "_Right") EndFunc Func _Nothing() sleep(100) EndFunc Link to comment Share on other sites More sharing options...
BrewManNH Posted October 19, 2012 Share Posted October 19, 2012 If you want to unregister a hotkey, just use HotKeySet("d") and then just set it back to what it was before, no need for a dummy function to handle it. Also, you don't need the braces around a hotkey unless it's a special key like ESC or the Windows key. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Aapjuh Posted October 19, 2012 Author Share Posted October 19, 2012 If you want to unregister a hotkey, just use HotKeySet("d") and then just set it back to what it was before, no need for a dummy function to handle it. Also, you don't need the braces around a hotkey unless it's a special key like ESC or the Windows key.hehe thnx taking out the dummy funcion has fixed the 2nd problem i was about to reply about (with dummy func i wasn't able to hold the key down for repeated moves)thnx alot 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