Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Loop function call more than once

$
0
0
Hi, im trying to write a code to increase/decrease a certain value (in this case is $r[1]) with using a hotkey. those values need to be looped at all times until the terminate function is called.
My problem here is the first loop for the both functions cannot be stopped if the functions have been called more than 1 times.

Im trying terminate the first loop of the functions before I call the same function again. Hope to avoid the recursion by randomly press the hotkey too many times, but still cant find the correct way to do that.

the result if i called the terminate function is this (after randomly press the increase/decrease button) :

-Increase STOP8
-Decrease STOP5
-Increase STOP8
-Decrease STOP5
-Increase STOP8
-Increase STOP8
-Decrease STOP5
-Decrease STOP5
-Decrease STOP5
-Decrease STOP5
-Decrease STOP5
-Increase STOP8

[ autoit ]         
Func _Increase() $terminate = 0 Global $lockDec = 0 Global $lockInc = 1 $up=$r[1]+3 If $up<50 Then Do ConsoleWrite("-Increase Running :" & $up & @CRLF) If $lockInc = 0 Then ExitLoop Sleep(100) Until $terminate = 1 or $lockInc = 0 ConsoleWrite("-Increase STOP" & $up & @CRLF) Else $up=50 Do ConsoleWrite("-Increase Running :" & $up & @CRLF) If $lockInc = 0 Then ExitLoop Sleep(100) Until $terminate = 1 or $lockInc = 0 ConsoleWrite("-Increase STOP" & $up & @CRLF) EndIf EndFunc Func _decrease() $terminate = 0 Global $lockDec = 1 Global $lockInc = 0 $down=$r[1]-3 If $down>8 Then Do ConsoleWrite("-Decrease Running :" & $down & @CRLF) Sleep(100) Until $terminate = 1 or $lockDec = 0 ConsoleWrite("-Decrease STOP" & $down & @CRLF) Else $down=5 Do ConsoleWrite("-Decrease Running :" & $down & @CRLF) Sleep(100) Until $terminate = 1 or $lockDec = 0 ConsoleWrite("-Decrease STOP" & $down & @CRLF) EndIf EndFunc Func _Terminate() $terminate = 1 EndFunc

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>