Jump to content
Sign in to follow this  
darkxraver

Do Loop Until Time Help

Recommended Posts

darkxraver

Hey i need some help with my script.. i just cant get it to work :/

First off heres what i got

Global $UnPaused
HotKeySet("{HOME}", "TogglePause")
HotKeySet("{END}", "Terminate")

While 1
    sleep(1)
WEnd


Func TogglePause()

    While 1
        
    $iRunTime = 5000
    $iBegin = TimerInit()
    
        Do
            MouseClick("left",950, 570, 5, 0)
            MouseClick("left",967, 570, 5, 0)
            sleep(50)
                
        Until TimerDiff($iBegin) >= $iRunTime
        
        
        sleep(10)
        Send("4")
        sleep(100)
        MouseClick(967, 505, 2, 0)
        sleep(100)
        send("1")
        sleep(10)

    WEnd

EndFunc


Func Terminate()
    Exit 0
EndFunc

What it does is it clicks 5 times on each spot, alternating between them (until i exit or pause the script), after 5 seconds while clicking it sends "4" followed by another mouseclick and "1".

What i would like it to do is: click each spot 5 times for 5 seconds, after 5 seconds stop the clicking and do the rest ("4", click, "1"), after that it should begin from start..

Would really appreciate the help!

Ty

Share this post


Link to post
Share on other sites
tlman12

Hey i need some help with my script.. i just cant get it to work :/

First off heres what i got

Global $UnPaused
HotKeySet("{HOME}", "TogglePause")
HotKeySet("{END}", "Terminate")

While 1
    sleep(1)
WEnd


Func TogglePause()

    While 1
        
    $iRunTime = 5000
    $iBegin = TimerInit()
    
        Do
            MouseClick("left",950, 570, 5, 0)
            MouseClick("left",967, 570, 5, 0)
            sleep(50)
                
        Until TimerDiff($iBegin) >= $iRunTime
        
        
        sleep(10)
        Send("4")
        sleep(100)
        MouseClick(967, 505, 2, 0)
        sleep(100)
        send("1")
        sleep(10)

    WEnd

EndFunc


Func Terminate()
    Exit 0
EndFunc

What it does is it clicks 5 times on each spot, alternating between them (until i exit or pause the script), after 5 seconds while clicking it sends "4" followed by another mouseclick and "1".

What i would like it to do is: click each spot 5 times for 5 seconds, after 5 seconds stop the clicking and do the rest ("4", click, "1"), after that it should begin from start..

Would really appreciate the help!

Ty

it looks like it works to me but I can't figure out exactly what your trying to do. if you want it to click "each spot 5 times for 5 seconds" them i'm assuming you want it to click each spot once ever 1 second which would mean you would have to change that sleep in the do loop to sleep(1000) 1000ms = 1s

other then that it appears to do exactly what your saying it should.

Share this post


Link to post
Share on other sites
pieeater

i made the pause toggling more effective, however it will still have to wait until the timer is done

Global $Paused = False
HotKeySet("{HOME}", "TogglePause")
HotKeySet("{END}", "Terminate")

While 1
    If $Paused Then
        $iRunTime = 5000
        $iBegin = TimerInit()
        Do
            MouseClick("left",950, 570, 5, 0)
            MouseClick("left",967, 570, 5, 0)
            sleep(50)
        Until TimerDiff($iBegin) >= $iRunTime

        sleep(10)
        Send("4")
        sleep(100)
        MouseClick(967, 505, 2, 0)
        sleep(100)
        send("1")
        sleep(10)
    EndIf
WEnd


Func TogglePause()
    $Paused = Not $Paused
EndFunc


Func Terminate()
    Exit 0
EndFunc

[spoiler]My UDFs: Login UDF[/spoiler]

Share this post


Link to post
Share on other sites
monoscout999

While $pause
?? its more effective

Share this post


Link to post
Share on other sites
tlman12

i made the pause toggling more effective, however it will still have to wait until the timer is done

Global $Paused = False
HotKeySet("{HOME}", "TogglePause")
HotKeySet("{END}", "Terminate")41

While 1
    If $Paused Then
        $iRunTime = 5000
        $iBegin = TimerInit()
        Do
            MouseClick("left",950, 570, 5, 0)
            MouseClick("left",967, 570, 5, 0)
            sleep(50)
        Until TimerDiff($iBegin) >= $iRunTime

        sleep(10)
        Send("4")
        sleep(100)
        MouseClick(967, 505, 2, 0)
        sleep(100)
        send("1")
        sleep(10)
    EndIf
WEnd


Func TogglePause()
    $Paused = Not $Paused
EndFunc


Func Terminate()
    Exit 0
EndFunc

so you are trying to be able to pause the script an any time within the script?

if thats the case try this

Global $Paused = True
HotKeySet("{HOME}", "TogglePause")
HotKeySet("{END}", "Terminate")

While 1
    $iRunTime = 5000
    $iBegin = TimerInit()
    Do
        MouseClick("left", 950, 570, 5, 0)
        MouseClick("left", 967, 570, 5, 0)
        Sleep(50)
    Until TimerDiff($iBegin) >= $iRunTime
    Sleep(10)
    Send("4")
    Sleep(100)
    MouseClick(967, 505, 2, 0)
    Sleep(100)
    Send("1")
    Sleep(10)
WEnd

Func TogglePause()
    $Paused = Not $Paused
    If $Paused Then
        Do
            Sleep(100)
        Until Not $Paused
    EndIf
EndFunc   ;==>TogglePause

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

of course if you pause during the timed portion then when you unpause chances are that timer will be expired and it will just continue on with the rest of the script. if you didn't want that then you have to do some math by getting the current timer subtracting it from the runtime and then resetting the runtime. like this.

Global $Paused = False
HotKeySet("{HOME}", "TogglePause")
HotKeySet("{END}", "Terminate")

While 1
    $iRunTime = 5000
    $iBegin = TimerInit()
    Do
        MouseClick("left", 950, 570, 5, 0)
        MouseClick("left", 967, 570, 5, 0)
        Sleep(50)
    Until TimerDiff($iBegin) >= $iRunTime
    Sleep(10)
    Send("4")
    Sleep(100)
    MouseClick(967, 505, 2, 0)
    Sleep(100)
    Send("1")
    Sleep(10)
WEnd

Func TogglePause()
    $Paused = Not $Paused
    If $Paused Then
        $iTimeLeft = $iRunTime - TimerDiff($iBegin)
        $iRunTime = $iTimeLeft
        Do
            Sleep(100)
        Until Not $Paused
        $iBegin = TimerInit()
    EndIf
EndFunc   ;==>TogglePause

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate
Edited by tlman12

Share this post


Link to post
Share on other sites
darkxraver

hey sry for the late reply

going to be more specific about what id like it to do and what it does atm.

so if i start my script which i posted i.e. in notepad, you can see that the mouse clicks 5 times ~a bit left of the middle and then 5 times a bit right of the middle of the screen (lets call this part 1 for you to understand it better). so far so good!

but now the problem part.. after 5 seconds (of part 1) it sends 4, a click and 1 to notepad while still doing part 1, which is what i dont want. i would like it to pause part 1 and then send 4, a click and 1 and then continue with part 1.

in short what it does now (wrong way):

-does part 1 continuously (until i stop or pause the script)

-after 5 seconds, it sends part 2 while still doing part 1 over and over

in short what it should do:

-do part 1 for 5 seconds

-after 5 seconds, stop part 1

-part 2 (send "4", click, "1")

-after part 2 is done, start with part 1 again and so on

so yeah hope i explained it a bit better now. thanks for your help so far

Edited by darkxraver

Share this post


Link to post
Share on other sites
tlman12

hey sry for the late reply

going to be more specific about what id like it to do and what it does atm.

so if i start my script which i posted i.e. in notepad, you can see that the mouse clicks 5 times ~a bit left of the middle and then 5 times a bit right of the middle of the screen (lets call this part 1 for you to understand it better). so far so good!

but now the problem part.. after 5 seconds (of part 1) it sends 4, a click and 1 to notepad while still doing part 1, which is what i dont want. i would like it to pause part 1 and then send 4, a click and 1 and then continue with part 1.

in short what it does now (wrong way):

-does part 1 continuously (until i stop or pause the script)

-after 5 seconds, it sends part 2 while still doing part 1 over and over

in short what it should do:

-do part 1 for 5 seconds

-after 5 seconds, stop part 1

-part 2 (send "4", click, "1")

-after part 2 is done, start with part 1 again and so on

so yeah hope i explained it a bit better now. thanks for your help so far

slowly but surly i think it's becoming clearer. but maybe not? heres my stab at it this time i tried 2 seperate

this one clicks each spot 1 time ever second so click 1 click 2 pause click 1 click 2 pause, then which ever click is on it pauses part 1 and does part to then resumes where it left on part 1.

Global $Paused = False
HotKeySet("{HOME}", "TogglePause")
HotKeySet("{END}", "Terminate")

$iBegin = TimerInit()
_Part1()


Func _Part1()
    While 1
        $iRunTime = 5000
        If TimerDiff($iBegin) >= $iRunTime Then _Part2()
        MouseClick("left", 950, 570, 5, 0)
        If TimerDiff($iBegin) >= $iRunTime Then _Part2()
        MouseClick("left", 967, 570, 5, 0))
        If TimerDiff($iBegin) >= $iRunTime Then _Part2()
        Sleep(1000)
    WEnd
EndFunc

Func _Part2()
    Sleep(10)
    Send("4")
    Sleep(100)
    MouseClick(967, 505, 2, 0)12
    Sleep(100)
    Send("1")
    Sleep(10)
    $iBegin = TimerInit()
EndFunc

Func TogglePause()
    $Paused = Not $Paused
    If $Paused Then
        $iTimeLeft = $iRunTime - TimerDiff($iBegin)
        $iRunTime = $iTimeLeft
        Do
            Sleep(100)
        Until Not $Paused
        $iBegin = TimerInit()
    EndIf
EndFunc   ;==>TogglePause

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

this one clicks each spot once per second click 1 click 2 pause ect... but finishes all 5 clicks on each spot after 5 seconds and does part 2 then restarts part 1 from the begining.

Global $Paused = False
HotKeySet("{HOME}", "TogglePause")
HotKeySet("{END}", "Terminate")


Dim $iRunTime


$iBegin = TimerInit()
_Part1()


Func _Part1()
    While 1
        $iRunTime = 5000
        MouseClick("left", 950, 570, 5, 0)
        MouseClick("left", 967, 570, 5, 0))
        Sleep(1000)
        If TimerDiff($iBegin) >= $iRunTime Then _Part2()
    WEnd
EndFunc

Func _Part2()
    Sleep(10)
    Send("4")
    Sleep(100)
    MouseClick(967, 505, 2, 0)
    Sleep(100)
    Send("1")
    Sleep(10)
    $iBegin = TimerInit()
EndFunc

Func TogglePause()
    $Paused = Not $Paused
    If $Paused Then
        $iTimeLeft = $iRunTime - TimerDiff($iBegin)
        $iRunTime = $iTimeLeft
        Do
            Sleep(100)
        Until Not $Paused
        $iBegin = TimerInit()
    EndIf
EndFunc   ;==>TogglePause

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

Share this post


Link to post
Share on other sites
darkxraver

slowly but surly i think it's becoming clearer. but maybe not? heres my stab at it this time i tried 2 seperate

this one clicks each spot 1 time ever second so click 1 click 2 pause click 1 click 2 pause, then which ever click is on it pauses part 1 and does part to then resumes where it left on part 1.

Global $Paused = False
HotKeySet("{HOME}", "TogglePause")
HotKeySet("{END}", "Terminate")

$iBegin = TimerInit()
_Part1()


Func _Part1()
    While 1
        $iRunTime = 5000
        If TimerDiff($iBegin) >= $iRunTime Then _Part2()
        MouseClick("left", 950, 570, 5, 0)
        If TimerDiff($iBegin) >= $iRunTime Then _Part2()
        MouseClick("left", 967, 570, 5, 0))
        If TimerDiff($iBegin) >= $iRunTime Then _Part2()
        Sleep(1000)
    WEnd
EndFunc

Func _Part2()
    Sleep(10)
    Send("4")
    Sleep(100)
    MouseClick(967, 505, 2, 0)12
    Sleep(100)
    Send("1")
    Sleep(10)
    $iBegin = TimerInit()
EndFunc

Func TogglePause()
    $Paused = Not $Paused
    If $Paused Then
        $iTimeLeft = $iRunTime - TimerDiff($iBegin)
        $iRunTime = $iTimeLeft
        Do
            Sleep(100)
        Until Not $Paused
        $iBegin = TimerInit()
    EndIf
EndFunc   ;==>TogglePause

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

this one clicks each spot once per second click 1 click 2 pause ect... but finishes all 5 clicks on each spot after 5 seconds and does part 2 then restarts part 1 from the begining.

Global $Paused = False
HotKeySet("{HOME}", "TogglePause")
HotKeySet("{END}", "Terminate")


Dim $iRunTime


$iBegin = TimerInit()
_Part1()


Func _Part1()
    While 1
        $iRunTime = 5000
        MouseClick("left", 950, 570, 5, 0)
        MouseClick("left", 967, 570, 5, 0))
        Sleep(1000)
        If TimerDiff($iBegin) >= $iRunTime Then _Part2()
    WEnd
EndFunc

Func _Part2()
    Sleep(10)
    Send("4")
    Sleep(100)
    MouseClick(967, 505, 2, 0)
    Sleep(100)
    Send("1")
    Sleep(10)
    $iBegin = TimerInit()
EndFunc

Func TogglePause()
    $Paused = Not $Paused
    If $Paused Then
        $iTimeLeft = $iRunTime - TimerDiff($iBegin)
        $iRunTime = $iTimeLeft
        Do
            Sleep(100)
        Until Not $Paused
        $iBegin = TimerInit()
    EndIf
EndFunc   ;==>TogglePause

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

Yes, Thank you! The seconds script of yours is what i needed. Sry for all the confusion

Edit: 1 more question - how to do it that the script starts in paused mode?

Edited by darkxraver

Share this post


Link to post
Share on other sites
Xandy

1 more question - how to do it that the script starts in paused mode?

I'm thinking you could either change:

Global $Paused = False to Global $Paused = true

or call TogglePause() say right before _Part1()

does that help?

edit: but don't do both at once, one or the other

Edited by songersoft

Share this post


Link to post
Share on other sites
darkxraver

I'm thinking you could either change:

Global $Paused = False to Global $Paused = true

or call TogglePause() say right before _Part1()

does that help?

edit: but don't do both at once, one or the other

Awesome!

Calling TogglePause() before _Part1() worked, but changing Global $Paused from False to True didnt work.

Thanks alot!

Share this post


Link to post
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
Sign in to follow this  

×