leuce Posted August 14, 2020 Share Posted August 14, 2020 (edited) Hello everyone I need to write a script that runs a For...Next loop during which the script will sometimes take too long to go to the next iteration, and I want the user to have the ability to press a hotkey to force the script to continue the loop immediately. FWIW, during each loop, the script will wait for the clipboard to change, but sometimes the clipboard isn't going to change and yet the user would want to move on to the next iteration. Obviously, this doesn't work: 🙂 HotKeySet("{SPACE}", "GoOn") While 1 Sleep (100) WEnd For $i = 1 to 10 [[some actions here]] Next Func GoOn() ContinueLoop EndFunc Do you have any advice for me? How can I set a hotkey (e.g. spacebar) which will cause a For...Next loop to continue the loop? Thanks Samuel Edited August 14, 2020 by leuce Link to comment Share on other sites More sharing options...
Gianni Posted August 14, 2020 Share Posted August 14, 2020 (edited) a possible way Global $bContinueLoop HotKeySet("{SPACE}", "GoOn") $sClipGet = ClipGet() ; initial peek of clipboard For $i = 1 To 10 Do ; wait for clipboard to change (or a forced iteration) Sleep(250) Until ($sClipGet <> ClipGet()) Or $bContinueLoop $sClipGet = ClipGet() ; put the new clipboard content to the $sClipGet variable If $bContinueLoop Then ConsoleWrite("iteration " & $i & " has been forced" & @CRLF) $bContinueLoop = False Else ConsoleWrite("iteration " & $i & " Clipboard has changed" & @CRLF) EndIf Next Func GoOn() $bContinueLoop = True EndFunc ;==>GoOn Edited August 14, 2020 by Chimp Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... 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