Jump to content

Loop function call more than once


VampS
 Share

Recommended Posts

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

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
Link to comment
Share on other sites

can you post the working script

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...