Jump to content

Im lost


Recommended Posts

ok i am trying to create a looping script,

Do

MouseClick( "left", 32,883, 1, 25)

MouseClick( "left", 52,446, 1, 50)

MouseClick( "left", 199,63, 1, 50)

$i = $i + 1

Until $i =1

Do

MouseClick( "left", 58,413, 1, 50)

MouseClick( "left", 328,389, 1, 50)

MouseClick( "left", 628,412, 1, 50)

MouseClick( "left", 385,454, 1, 50)

MouseClick( "left", 844,205, 1, 50)

$j = $j + 1

Until $j =1

Do

MouseClick( "left", 255,64, 1, 25)

MouseClick( "left", 177,300, 1, 25)

$k = $k + 1

Until $k =4

Do

MouseClick( "left", 439,298, 1, 100)

$o = $o + 1

Until $o =1

sleep(500)

Do

MouseClick( "left", 1418,7, 1, 100)

$ccc = $ccc + 1

Until $ccc =1

While 1

Sleep(100)

WEnd

Func TogglePause()

$Paused = NOT $Paused

While $Paused

sleep(100)

ToolTip('Script is "Paused"',0,0)

WEnd

ToolTip("")

EndFunc

Func Terminate()

Exit 0

EndFunc

is there any way i could say run this once it reaches the end, pause it for a while and then restart from the begining again? i have tried reading the help guide but i just cant figure it out, any help would be greatly appriciated

Thanks

Link to comment
Share on other sites

This is one way to do it.

ps. use code, or autoit tags when posting code.

Local $time = 5*60*1000 ;this is the time of miliseconds between function calls (5 minutes) you could also just use 300000, but this is more readable.

While 1
    _Main()
    Sleep($time)
WEnd

Func _Main() ;I put all your code in this function to make it easy to call it multiple times. You could also just place the original code directly in the while loop
    Do
        MouseClick("left", 32, 883, 1, 25)
        MouseClick("left", 52, 446, 1, 50)
        MouseClick("left", 199, 63, 1, 50)
        $i = $i + 1
    Until $i = 1
    Do
        MouseClick("left", 58, 413, 1, 50)
        MouseClick("left", 328, 389, 1, 50)
        MouseClick("left", 628, 412, 1, 50)
        MouseClick("left", 385, 454, 1, 50)
        MouseClick("left", 844, 205, 1, 50)
        $j = $j + 1
    Until $j = 1
    Do
        MouseClick("left", 255, 64, 1, 25)
        MouseClick("left", 177, 300, 1, 25)
        $k = $k + 1
    Until $k = 4
    Do
        MouseClick("left", 439, 298, 1, 100)
        $o = $o + 1
    Until $o = 1
    Sleep(500)
    Do
        MouseClick("left", 1418, 7, 1, 100)
        $ccc = $ccc + 1
    Until $ccc = 1
EndFunc

Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc ;==>TogglePause

Func Terminate()
    Exit 0
EndFunc ;==>Terminate
Link to comment
Share on other sites

This is one way to do it.

ps. use code, or autoit tags when posting code.

Local $time = 5*60*1000 ;this is the time of miliseconds between function calls (5 minutes) you could also just use 300000, but this is more readable.

While 1
    _Main()
    Sleep($time)
WEnd

Func _Main() ;I put all your code in this function to make it easy to call it multiple times. You could also just place the original code directly in the while loop
    Do
        MouseClick("left", 32, 883, 1, 25)
        MouseClick("left", 52, 446, 1, 50)
        MouseClick("left", 199, 63, 1, 50)
        $i = $i + 1
    Until $i = 1
    Do
        MouseClick("left", 58, 413, 1, 50)
        MouseClick("left", 328, 389, 1, 50)
        MouseClick("left", 628, 412, 1, 50)
        MouseClick("left", 385, 454, 1, 50)
        MouseClick("left", 844, 205, 1, 50)
        $j = $j + 1
    Until $j = 1
    Do
        MouseClick("left", 255, 64, 1, 25)
        MouseClick("left", 177, 300, 1, 25)
        $k = $k + 1
    Until $k = 4
    Do
        MouseClick("left", 439, 298, 1, 100)
        $o = $o + 1
    Until $o = 1
    Sleep(500)
    Do
        MouseClick("left", 1418, 7, 1, 100)
        $ccc = $ccc + 1
    Until $ccc = 1
EndFunc

Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc ;==>TogglePause

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

i have tried running this, it does loop it so thanks for that but it runs it and then just loops the very first 4 clicks, am i doing somthing wrong?
Link to comment
Share on other sites

i have tried running this, it does loop it so thanks for that but it runs it and then just loops the very first 4 clicks, am i doing somthing wrong?

I don't see where you declare your variables $i, $j etc. You need to reset these values to zero at the start of every repeat.
Link to comment
Share on other sites

I don't see where you declare your variables $i, $j etc. You need to reset these values to zero at the start of every repeat.

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage")
$i = 0
$j = 0
$k = 0
$m = 0
$l = 0
$o = 0
$p = 0
$q = 0
$a = 0
$b = 0
$c = 0
$r = 0
$s = 0
$t = 0
$u = 0
$v = 0
$w = 0
$x = 0
$y = 0
$z = 0
$n = 0
$d = 0
$e = 0
$f = 0
$k = 0
$aa = 0
$bb = 0
$cc = 0
$dd = 0
$ee = 0
$ff = 0
$gg = 0
$hh = 0
$kk = 0
$ccc = 0
Local $time = 0.1*60*1000
While 1
    _Main()
    Sleep($time)
WEnd

Func _Main()
    Do
        MouseClick("left", 32, 883, 1, 25)
        MouseClick("left", 52, 446, 1, 50)
        MouseClick("left", 199, 63, 1, 50)
        $i = $i + 1
    Until $i = 1
    Do
        MouseClick("left", 58, 413, 1, 50)
        MouseClick("left", 328, 389, 1, 50)
        MouseClick("left", 628, 412, 1, 50)
        MouseClick("left", 385, 454, 1, 50)
        MouseClick("left", 844, 205, 1, 50)
        $j = $j + 1
    Until $j = 1
    Do
        MouseClick("left", 255, 64, 1, 25)
        MouseClick("left", 177, 300, 1, 25)
        $k = $k + 1
    Until $k = 4
    Do
        MouseClick("left", 439, 298, 1, 100)
        $o = $o + 1
    Until $o = 1
    Sleep(500)
    Do
        MouseClick("left", 1418, 7, 1, 100)
        $ccc = $ccc + 1
    Until $ccc = 1
EndFunc

Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    exit 0
EndFunc

how do i reset the values at the end?

Edited by Roy2010
Link to comment
Share on other sites

Maybe something like this:

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage")

Local $time = 0.1*60*1000
Local $i, $j, $k, $o, $ccc

While 1
    _ResetValues()
    _Main()
    Sleep($time)
WEnd

Func _ResetValues()
    $i = 0
    $j = 0
    $k = 0
    $o = 0
    $ccc = 0
EndFunc

Func _Main()
    Do
        MouseClick("left", 32, 883, 1, 25)
        MouseClick("left", 52, 446, 1, 50)
        MouseClick("left", 199, 63, 1, 50)
        $i = $i + 1
    Until $i = 1
    Do
        MouseClick("left", 58, 413, 1, 50)
        MouseClick("left", 328, 389, 1, 50)
        MouseClick("left", 628, 412, 1, 50)
        MouseClick("left", 385, 454, 1, 50)
        MouseClick("left", 844, 205, 1, 50)
        $j = $j + 1
    Until $j = 1
    Do
        MouseClick("left", 255, 64, 1, 25)
        MouseClick("left", 177, 300, 1, 25)
        $k = $k + 1
    Until $k = 4
    Do
        MouseClick("left", 439, 298, 1, 100)
        $o = $o + 1
    Until $o = 1
    Sleep(500)
    Do
        MouseClick("left", 1418, 7, 1, 100)
        $ccc = $ccc + 1
    Until $ccc = 1
EndFunc

Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    exit 0
EndFunc
Link to comment
Share on other sites

Maybe something like this:

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage")

Local $time = 0.1*60*1000
Local $i, $j, $k, $o, $ccc

While 1
    _ResetValues()
    _Main()
    Sleep($time)
WEnd

Func _ResetValues()
    $i = 0
    $j = 0
    $k = 0
    $o = 0
    $ccc = 0
EndFunc

Func _Main()
    Do
        MouseClick("left", 32, 883, 1, 25)
        MouseClick("left", 52, 446, 1, 50)
        MouseClick("left", 199, 63, 1, 50)
        $i = $i + 1
    Until $i = 1
    Do
        MouseClick("left", 58, 413, 1, 50)
        MouseClick("left", 328, 389, 1, 50)
        MouseClick("left", 628, 412, 1, 50)
        MouseClick("left", 385, 454, 1, 50)
        MouseClick("left", 844, 205, 1, 50)
        $j = $j + 1
    Until $j = 1
    Do
        MouseClick("left", 255, 64, 1, 25)
        MouseClick("left", 177, 300, 1, 25)
        $k = $k + 1
    Until $k = 4
    Do
        MouseClick("left", 439, 298, 1, 100)
        $o = $o + 1
    Until $o = 1
    Sleep(500)
    Do
        MouseClick("left", 1418, 7, 1, 100)
        $ccc = $ccc + 1
    Until $ccc = 1
EndFunc

Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    exit 0
EndFunc

Thankyou
Link to comment
Share on other sites

umm if they start at 0 why even use Do... Until on some of those because they stop at 1 so only run once anyway. And why not use for if it does need repeating to avoid declaring or resetting variables anyway.

Here this should do the same thing as above.

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")

Local $time = 0.1*60*1000

While True
    _Main()
    Sleep($time)
WEnd

Func _Main()
    MouseClick("left", 32, 883, 1, 25)
    MouseClick("left", 52, 446, 1, 50)
    MouseClick("left", 199, 63, 1, 50)
    MouseClick("left", 58, 413, 1, 50)
    MouseClick("left", 328, 389, 1, 50)
    MouseClick("left", 628, 412, 1, 50)
    MouseClick("left", 385, 454, 1, 50)
    MouseClick("left", 844, 205, 1, 50)
    For $i = 1 To 4
        MouseClick("left", 255, 64, 1, 25)
        MouseClick("left", 177, 300, 1, 25)
    Next
    MouseClick("left", 439, 298, 1, 100)
    Sleep(500)
    MouseClick("left", 1418, 7, 1, 100)
EndFunc

Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    exit 0
EndFunc
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...