Jump to content

Can't exit the GUI/Script


Recommended Posts

Hey guys,

I was trying to create a script with a GUI but when I start the script via pressing the startbutton in my GUI and then trying to stop the script it won't close/stop.

Here is the script:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
Global $GUI = GUICreate("AlphaAgility", 218, 65, 1147, 123)
Global $StartButton = GUICtrlCreateButton("Start", 24, 16, 75, 25)
Global $StopButton = GUICtrlCreateButton("Stop", 120, 16, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $StartButton
            while(1)
            Agility()
            WEnd
        Case $StopButton
            Exit
    EndSwitch
WEnd

Global $agility = False


Func Agility()
    MouseClick("Left",random(466,500),random(634,669),1,random(10,20));Balancier-Stamm
        If Not(@error) Then
        $agility = True
        sleep(random(0,200))
        MouseMove(random(408,661),random(632,749),random(10,20));random Mousemovement Balancier-Stamm
        Else
        EndIf
    sleep(5500)
    MouseClick("Left",448,820,1,random(10,20));Netz
        If Not(@error) Then
        $agility = True
        sleep(random(0,200))
        MouseMove(random(334,557),random(774,876),random(10,20));random Mousemovement Netz
        Else
        $agility = False
        EndIf
    sleep(3750)
    MouseClick("Left",480,706,1,random(10,20));Ast
    If Not(@error) Then
        $agility = True
        ;sleep(random(0,200))
        ;MouseMove(random(95,953),random(117,1067),random(10,20)) -> kein random Mousemovement nötig
        Else
        $agility = False
        EndIf
    sleep(2750)
    MouseClick("Left",727,608,1,random(10,20));Balancier-Seil
    If Not(@error) Then
        $agility = True
        sleep(random(0,200))
        MouseMove(random(723,891),random(572,676),random(10,20));random Mousemovement Balancier-Seil
        Else
        $agility = False
        EndIf
    sleep(6750)
    MouseClick("Left",698,633,1,random(10,20));Ast
    If Not(@error) Then
        $agility = True
        ;sleep(random(0,200))
        ;MouseMove(random(95,953),random(117,1067),random(10,20)) -> kein random Mousemovement nötig
        Else
        $agility = False
        EndIf
    sleep(4000)
    MouseClick("Left",random(372,459),random(136,202),1,random(10,20));Netz
    If Not(@error) Then
        $agility = True
        sleep(random(0,200))
        MouseMove(random(388,510),random(140,212),random(10,20));random Mousemovement Netz
        Else
        $agility = False
        EndIf
    sleep(6250)
    MouseClick("Left",random(362,401),random(363,409),1,random(10,20));Röhre
    If Not(@error) Then
        $agility = True
        ;sleep(random(0,200))
        ;MouseMove(random(95,953),random(117,1067),random(10,20)) -> kein random Mousemovement nötig
        Else
        $agility = False
        EndIf
    sleep(7000)
    MouseClick("Left",14,654,1,random(10,20));Startposition
        If Not(@error) Then
        $agility = True
        ;sleep(random(0,200))
        ;MouseMove(random(388,510),random(140,212),random(10,20)) -> kein random Mousemovement nötig
        Else
        EndIf
    sleep(4000)
EndFunc

Thanks in advance

Jannik Rendl

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

×
×
  • Create New...