WoodGrain Posted April 16, 2005 Posted April 16, 2005 Hi guys, I'm trying to call an "ExitLoop" with a hotkey function reference. AutoIt won't let me run the script, saying that "ExitLoop" must be run inside a loop. A cut down example would be: __________________________________ HotKeySet("+{F12}", "ExitLoopPause") WHILE 1 Sleep(500) WEND Func ExitLoopPause ExitLoop EndFunc
steveR Posted April 16, 2005 Posted April 16, 2005 (edited) That's not how ExitLoop is used. It's only used inside For, While, Do loop structures. If you need to exit the script when the hotkey is pressed, try this: HotKeySet("+{F12}", "ExitLoopPause") WHILE 1 Sleep(500) WEND Func ExitLoopPause Exit EndFunc Edited April 16, 2005 by steveR AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
WoodGrain Posted April 16, 2005 Author Posted April 16, 2005 I don't want to exit the whole program, just the loop..That's not how ExitLoop is used. It's only used inside For, While, Do loop structures. If you need to exit the script when the hotkey is pressed, try this:HotKeySet("+{F12}", "ExitLoopPause") WHILE 1 Sleep(500) WEND Func ExitLoopPause Exit EndFunc<{POST_SNAPBACK}>
Developers Jos Posted April 16, 2005 Developers Posted April 16, 2005 I don't want to exit the whole program, just the loop..<{POST_SNAPBACK}>HotKeySet("+{F12}", "ExitLoopPause") $Looping = 1 WHILE $Looping Sleep(500) WEND Func ExitLoopPause $Looping = NOT $Looping EndFunc SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
steveR Posted April 16, 2005 Posted April 16, 2005 If you wanted a toggle, do something like this: opt("wintitlematchmode", 2) run("notepad") winwaitactive("Notepad") HotKeySet("x","_exit") HotKeySet("a","_toggle") $flag = 0 While 1 sleep(10) if $flag then _flash() Wend func _exit() Exit EndFunc Func _flash() DllCall("user32.dll", "int", "FlashWindow", "hWnd", WinGetHandle("Notepad"), "int", 1) sleep(100) EndFunc Func _toggle() if $flag then $flag = 0 Else $flag = 1 EndIf EndFunc AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
WoodGrain Posted April 16, 2005 Author Posted April 16, 2005 Thanks.Worked nicely Also worth noting, you can't use F12; from the help file "It is also reserved by Windows, according to its API."Made basic changes to suit script..$Looping = 1 WHILE $Looping = 1 Sleep(500)WENDFunc ExitLoopPause $Looping = 0EndFuncCheers.HotKeySet("+{F12}", "ExitLoopPause") $Looping = 1 WHILE $Looping Sleep(500) WEND Func ExitLoopPause $Looping = NOT $Looping EndFunc<{POST_SNAPBACK}>
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