Jump to content
Sign in to follow this  
vicev

Button To Stop A Do Until Loop Within A Start Button Function

Recommended Posts

vicev

Here is what i have. I've searched the forums, and whilst many others asked for ways to do this, I was unable to find something specific to this problem. Be it my poor searching skills, or just poor eyesight, I'm wondering if someone could give me a little insight.

At the moment, as soon as the start button is pressed, we are stuck inside the loop until the script is manually halted or terminated. No hotkey pause functions work, pressing the X in the top right corner, nothing that i have tried.

Thanks for taking a look.

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)  
$mainwindow = GUICreate("Slots", 70, 80, 10, 500, -1,$WS_EX_TOPMOST) 

GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

$start = GUICtrlCreateButton ("Start",  10, 10, 50)
$stop = GUICtrlCreateButton ("Stop",  10, 45, 50)

GUICtrlSetOnEvent($start, "y")
GUICtrlSetOnEvent($stop, "n")

GUISetState(@SW_SHOW)


While 1
  Sleep(1000) 
WEnd


Func y()

sleep(2000)

$o = 1
Do
    $i = 1
    Do
        MouseMove(165, 341, 0)
        mouseclick("left", 165, 341, 1)
        sleep("1500")
        MouseMove(249, 341, 0)
        mouseclick("left", 249, 341, 1)
        sleep("1500")
        MouseMove(331, 341, 0)
        mouseclick("left", 331, 341, 1)
        MouseMove(982, 436, 0)
        mouseclick("right", 982, 436, 1)
        MouseMove(580, 575, 0)
        mouseclick("left", 580, 575, 1)
        MouseMove(1025, 436, 0)
        mouseclick("right", 1025, 436, 1)
        MouseMove(580, 575, 0)
        mouseclick("left", 580, 575, 1)
        sleep("50")
        $i = $i + 1
    Until $i = 20
    
    send("{ESC}")
    sleep("2000")
    MouseMove(982, 436, 0)
    mouseclick("right", 982, 436, 1)
    MouseMove(580, 575, 0)
    mouseclick("left", 580, 575, 1)
    MouseMove(1025, 436, 0)
    mouseclick("right", 1025, 436, 1)
    MouseMove(580, 575, 0)
    mouseclick("left", 580, 575, 1)
Until $o = 2

EndFunc


Func n()
EndFunc

Func CLOSEClicked()
 Exit
EndFunc

Share this post


Link to post
Share on other sites
Valuater

maybe

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)

Dim $on = 2

$mainwindow = GUICreate("Slots", 70, 80, 10, 500, -1, $WS_EX_TOPMOST)

GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

$start = GUICtrlCreateButton("Start", 10, 10, 50)
$stop = GUICtrlCreateButton("Stop", 10, 45, 50)

GUICtrlSetOnEvent($start, "y")
GUICtrlSetOnEvent($stop, "n")

GUISetState(@SW_SHOW)


While 1
    If $on = 1 Then
        Sleep(2000)
        Do
            $i = 1
            Do
                MouseMove(165, 341, 0)
                MouseClick("left", 165, 341, 1)
                Sleep("1500")
                MouseMove(249, 341, 0)
                MouseClick("left", 249, 341, 1)
                Sleep("1500")
                MouseMove(331, 341, 0)
                MouseClick("left", 331, 341, 1)
                MouseMove(982, 436, 0)
                MouseClick("right", 982, 436, 1)
                MouseMove(580, 575, 0)
                MouseClick("left", 580, 575, 1)
                MouseMove(1025, 436, 0)
                MouseClick("right", 1025, 436, 1)
                MouseMove(580, 575, 0)
                MouseClick("left", 580, 575, 1)
                Sleep("50")
                $i = $i + 1
            Until $i = 20 Or $on = 2
            
            Send("{ESC}")
            Sleep("2000")
            MouseMove(982, 436, 0)
            MouseClick("right", 982, 436, 1)
            MouseMove(580, 575, 0)
            MouseClick("left", 580, 575, 1)
            MouseMove(1025, 436, 0)
            MouseClick("right", 1025, 436, 1)
            MouseMove(580, 575, 0)
            MouseClick("left", 580, 575, 1)
        Until $on = 2
    EndIf
    Sleep(10)
WEnd


Func y()
$on = 1
EndFunc ;==>y


Func n()
$on = 2
EndFunc ;==>n

Func CLOSEClicked()
    Exit
EndFunc ;==>CLOSEClicked

not tested

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
vicev

Oh Brilliant,

When i saw that i nearly kicked myself.

It works.

Finishes off one loop, but that can easily be fixed with a bit of tweaking, and for the application, it's not too important if it's a little sloppy.

Thanks Val

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.