Sign in to follow this  
Followers 0
HAWKZX

Loop with 2 varables

9 posts in this topic

My only other idea, which i am not sure where to look, or how to do it is ....

"DO" ABC

"UNTIL" DEF

"OR UNTIL" X timer (ie 10 mins expires)

original thread http://www.autoitscript.com/forum/index.php?showtopic=39393 but the topic changed after it was answered.

Func cycle()
Sleep(150000)
Send("{F1}") ;turn off then back on
    MouseMove(851, 647)
    Sleep(5000)
If (PixelGetColor(851, 647) > 10000000) Then empty()
    Sleep(500)
    MouseMove(1704,82)  ; target 1
    MouseDown("left")
    MouseUp("left")
    Send("{F1}")
If (PixelGetColor(1509, 62) = 0) Then target()
    
Sleep(11000)

Send("{F2}") ;turn off then back on
    MouseMove(851, 647)
    Sleep(5000)
If (PixelGetColor(851, 647) > 10000000) Then empty()
    Sleep(500)
    MouseMove(1591,70)  ; target 2
    MouseDown("left")
    MouseUp("left")
    Send("{F2}")
If (PixelGetColor(1509, 62) = 0) Then target()

Sleep(11000)

Send("{F3}") ;turn off then back on
    MouseMove(851, 647)
    Sleep(5000)
If (PixelGetColor(851, 647) > 10000000) Then empty()
    Sleep(500)
    MouseMove(1493,77)  ; target 3
    MouseDown("left")
    MouseUp("left")
    Send("{F3}")
If (PixelGetColor(1509, 62) = 0) Then target()
    Sleep(500)

cycle()
EndFunc

Just looking to add a "if" 10 minutes pass "Then empty()" just not sure how to set up the timer or add the second varable.

Share this post


Link to post
Share on other sites



next day bump for ideas

Share this post


Link to post
Share on other sites

Perhaps have a loop that sleeps for 1 second, then adds 1 to a variable and when that variable reaches how every many seconds are in time minutes, you have it do something.


[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

Share this post


Link to post
Share on other sites

Func cycle()
$timer = TimerInit ()
Sleep(150000)
Send("{F1}") ;turn off then back on
    MouseMove(851, 647)
    Sleep(5000)
If (PixelGetColor(851, 647) > 10000000) Then empty()
    Sleep(500)
    MouseMove(1704,82)  ; target 1
    MouseDown("left")
    MouseUp("left")
    Send("{F1}")
If (PixelGetColor(1509, 62) = 0) Then target()
   
Sleep(11000)

Send("{F2}") ;turn off then back on
    MouseMove(851, 647)
    Sleep(5000)
If (PixelGetColor(851, 647) > 10000000) Then empty()
    Sleep(500)
    MouseMove(1591,70)  ; target 2
    MouseDown("left")
    MouseUp("left")
    Send("{F2}")
If (PixelGetColor(1509, 62) = 0) Then target()

Sleep(11000)

Send("{F3}") ;turn off then back on
    MouseMove(851, 647)
    Sleep(5000)
If (PixelGetColor(851, 647) > 10000000) Then empty()
    Sleep(500)
    MouseMove(1493,77)  ; target 3
    MouseDown("left")
    MouseUp("left")
    Send("{F3}")
If (PixelGetColor(1509, 62) = 0) Then target()
    Sleep(500)
If TimerDiff ( $timer ) = 10000 Then empty()
cycle()
EndFunc

Untested but should work

Share this post


Link to post
Share on other sites

$timer = TimerInit ()

If TimerDiff ( $timer ) = 10000 Then empty()

i moved starter to the end of the targeting and had to change to

If TimerDiff ( $timer ) > 10000 Then empty()

as the odds of ending on exactly 10000 (XYZ) are really slim. Thanks for the help IT WORKS! :)

Share this post


Link to post
Share on other sites

If that script runs for more than an hour or so, you'll probably get a recursion error.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I have yet to have that happen, as the loop is usually less then 10 mins, but this why I was seeking a second "out" of the loop.

Works great if it is in the same function, but as soon as i move the "$timer = TimerInit ()" to the end of the function before this one i get an error on the "If TimerDiff ( $timer ) > 10000 Then empty()" is not defined.

I only want the time to be set once per cycle I figured the easiest way to do that was to put it before this cycle.

Any thoughs?

Share this post


Link to post
Share on other sites

next day bump

Share this post


Link to post
Share on other sites

My only other idea, which i am not sure where to look, or how to do it is ....

"DO" ABC

"UNTIL" DEF

"OR UNTIL" X timer (ie 10 mins expires)

Haven't really looked much at your script, but here's one way to do what you asked above.

HotKeySet('{F2}', 'var2true')

$counter = 1
$timer = TimerInit()
$var = False

Do
    ToolTip('Loop iteration: ' & $counter)
    $counter += 1
    Sleep(50)
Until TimerDiff($timer) > 600000 Or $var = True

Func var2true()
    $var = True
EndFunc

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  
Followers 0