Jump to content

Recommended Posts

Posted (edited)

hi i need a little help with my scrip. here the script. what i want it to do is to pause when it loop 30 time.

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


MsgBox(4096, "click", "ok", 5)

MouseClick ( "left" , 268, 486 , 1, 3)
MouseClick ( "left" , 452, 186 , 1, 3)
Sleep ( 100 )
MouseClick ( "left")
Sleep ( 75 )
MouseClick ( "right")
Sleep ( 100 )
MouseClick ( "right")

MouseClick ( "left" , 205, 100 , 1, 3)

$i = 0
Do
MouseClick ( "right" , 130, 205 , 2, 3)
MouseClick ( "left" , 268, 486 , 1, 3)
MouseClick ( "left" , 452, 186 , 1, 3)
Sleep ( 120 )
MouseClick ( "left")
Sleep ( 100 )
MouseClick ( "right")
Sleep ( 100 )
MouseClick ( "right")

$i = $i + 1

Until $i = 30

Stuck here don't know how to end it to pause

Edited by whoRu
  • Moderators
Posted

Well, what I'll show you will 'Pause', but if that's all your script, as soon as you 'unpause' (by pressing the pause button) there is no loop to continue anywhere so it will exit.

Until $i = 30

Send('{PAUSE}')

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

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.

Posted

thanks for your help SmOke_N. how do u make it not to exit when u unpause and just start over with the script again?

Posted

I am not an AutoIt expert but I think put a loop round the code you want repeated, with no exit condition is one way.

For example:

$j = 1

Do

;code you want to repeat including the pause

until $j = 0

Posted

i had a sript that i wanted to keep looping until you told it not to and this was how i got around it.

hope this helps

work(); calls the main script the first time.

; looping statement that prompts if you want to continue 
$i = -1
While $i <> 1
    message()
    $i = $i
WEnd
    


; functions in here that will be called

Func work()
;   main part of script in here
EndFunc


Func message()
    If Not IsDeclared("iMsgBoxAnswer") Then Dim $iMsgBoxAnswer
    $iMsgBoxAnswer = MsgBox(36,"More ??","do you want to rerun ?")
    Select
       Case $iMsgBoxAnswer = 6;Yes
        work()
       Case $iMsgBoxAnswer = 7;No
        Exit
    EndSelect
EndFunc
Posted

If you only want the second part to run everytime you pause then use the following...

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

Stuff1()

While 1
    Stuff2()
    SEND("{PAUSE}")
WEnd

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

Func Terminate()
    Exit
EndFunc

Func Stuff1()
    MsgBox(4096, "click", "ok", 5)

    MouseClick ( "left" , 268, 486 , 1, 3)
    MouseClick ( "left" , 452, 186 , 1, 3)
    Sleep ( 100 )
    MouseClick ( "left")
    Sleep ( 75 )
    MouseClick ( "right")
    Sleep ( 100 )
    MouseClick ( "right")
    
    MouseClick ( "left" , 205, 100 , 1, 3)
EndFunc

Func Stuff2()
    For $i = 0 To 30 Step 1
        MouseClick ( "right" , 130, 205 , 2, 3)
        MouseClick ( "left" , 268, 486 , 1, 3)
        MouseClick ( "left" , 452, 186 , 1, 3)
        Sleep ( 120 )
        MouseClick ( "left")
        Sleep ( 100 )
        MouseClick ( "right")
        Sleep ( 100 )
        MouseClick ( "right")
    Next
EndFunc

If you want the whole script to run each time the second part has finished 30 then use the following.

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

While 1
        Stuff1()
    Stuff2()
    SEND("{PAUSE}")
WEnd

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

Func Terminate()
    Exit
EndFunc

Func Stuff1()
    MsgBox(4096, "click", "ok", 5)

    MouseClick ( "left" , 268, 486 , 1, 3)
    MouseClick ( "left" , 452, 186 , 1, 3)
    Sleep ( 100 )
    MouseClick ( "left")
    Sleep ( 75 )
    MouseClick ( "right")
    Sleep ( 100 )
    MouseClick ( "right")
    
    MouseClick ( "left" , 205, 100 , 1, 3)
EndFunc

Func Stuff2()
    For $i = 0 To 30 Step 1
        MouseClick ( "right" , 130, 205 , 2, 3)
        MouseClick ( "left" , 268, 486 , 1, 3)
        MouseClick ( "left" , 452, 186 , 1, 3)
        Sleep ( 120 )
        MouseClick ( "left")
        Sleep ( 100 )
        MouseClick ( "right")
        Sleep ( 100 )
        MouseClick ( "right")
    Next
EndFunc

I hope the above helps some.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

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
  • Recently Browsing   0 members

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