justinblack Posted January 27, 2010 Share Posted January 27, 2010 (edited) expandcollapse popupHotKeySet("{PAUSE}","activate") HotKeySet("{PAUSE}","inactive") While 1 $a = 0 inactive() $a = 0 start() WEnd func inactive() Do Until $a = 1 EndFunc func activate() $a = 1 EndFunc func start() Do Send('{LEFT DOWN}') Sleep(Random(6000,100000) Send('{LEFT UP}') Sleep(Random(10000,240000)) Send('{RIGHT DOWN}') Sleep(Random(2000,11000) Send('{RIGHT UP}') Sleep(Random(120000,240000)) Until $a = 1 EndFunc func quit() Exit EndFunc My assumption is that by hitting the PAUSE key the script will activate and continue until I hit PAUSE again. Also I want the script to press the LEFT and RIGHT arrow keys for random amounts of time. But I can't seem to get it working. Any tips? Thanks!!! Edited January 27, 2010 by justinblack Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 27, 2010 Share Posted January 27, 2010 HotKeySet() calls ONE function for the keystroke. You set that function for "{PAUSE}" to "activate", then immediately changed it to "inactivate". The end result is "inactivate" get called every time you hit "{PAUSE}". To fix it, just use one Global variable as a flag, and toggle it each time the hotkey is pressed with a single function: Global $f_Run = False Global $iVar = 0 HotKeySet("{PAUSE}", "_Pause") HotKeySet("{ESC}", "quit") While 1 If $f_Run Then $iVar += 1 ToolTip("$iVar = " & $iVar) EndIf Sleep(500) WEnd Func _Pause() $f_Run = Not $f_Run EndFunc ;==>inactive Func quit() Exit EndFunc ;==>quit Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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