Jump to content
Sign in to follow this  
supraaxdd

Second GUI doesn't close despite of there being a case to close it

Recommended Posts

Hello.

I am a fairly new scripter to this language but know some tricks or some terms used.

I have a problem with the update log closing despite of there being a case for the close button. It may be the second GUISetState to @SW_SHOW telling the Update Log to start up too. I tried disabling and enabling it, nothing works. I have no idea how to fix it and I sat for a while thinking how and I ran out of ideas. I know that there are excellent experts within this community and I believe that this community can help me yet again. Here is the script:

 

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$MainGUI = GUICreate("Internet Test", 400, 200, -1, -1)
$GroupBox1 = GUICtrlCreateLabel("Do you want to start testing your internet connection on your device?", 40, 50, 400, 20)
$AusWarn = GUICtrlCreateLabel("Note: Australia, South America and South Africa will not always" & @CRLF & "be pinged due to an unsteady connection.", 40, 80, 400, 40)
GUICtrlCreateGroup("", -1, -1, 1, 1)
$ButtonYes = GUICtrlCreateButton("&Yes", 230, 160, 75, 25)
$ButtonCan = GUICtrlCreateButton("&Cancel", 310, 160, 75, 25)
$ButtonUpL = GUICtrlCreateButton("Update Log", 10, 160, 75, 25)
GUISetState(@SW_SHOW)
$UpdGUI = GUICreate("Update Log", 400, 600, -1, -1)
$UpdGUILabel = GUICtrlCreateLabel("Update Log for v1.0.1:" & @CR & @CR & "- Changed the Australian IP for better connections." & @CR &  "- Displays the IP/Website the tool pinged" & @CR & @CR & @CR & "Update Log for v1.0.2" & @CR & @CR & "- Displays the IP/Website the tool pinged" & @CR & "- Added support for Middle East, South Africa, Asia and South America" & @CR & @CR & @CR & "Update Log for v1.0.3" & @CR & @CR & "- Added the Update Log" & @CR & "- Edited the note saying that some more regions may be buggy." & @CR & "", 40, 30, 400, 600)
$ButtonCloseUpd = GUICtrlCreateButton("Close", 175, 560, 75, 25)
GUISetState(@SW_SHOW)
;~ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
$GUI2 = GUICreate("Which Region?", 400, 200, -1, -1)
$ButtonEU = GUICtrlCreateButton("Europe", 10, 20, 80, 30)
$ButtonNA = GUICtrlCreateButton("North America", 110, 20, 80, 30)
$ButtonAU = GUICtrlCreateButton("Australia", 210, 20, 80, 30)
$ButtonAS = GUICtrlCreateButton("Asia", 310, 20, 80, 30)
$ButtonSA = GUICtrlCreateButton("South America", 10, 60, 80, 30)
$ButtonAF = GUICtrlCreateButton("South Africa", 110, 60, 80, 30)
$ButtonME = GUICtrlCreateButton("Middle East", 210, 60, 80, 30)
$GUIConnecting = GUICreate("Connecting...",200,100,-1,-1)
$LabelConn = GUICtrlCreateLabel("Connecting..." ,40, 50, 400, 20)
GUISetState(@SW_HIDE, $GUI2)
GUISetState(@SW_HIDE, $ButtonEU)
GUISetState(@SW_HIDE, $ButtonNA)
GUISetState(@SW_HIDE, $ButtonAU)
GUISetState(@SW_HIDE, $ButtonAS)
GUISetState(@SW_HIDE, $ButtonAF)
GUISetState(@SW_HIDE, $ButtonME)
GUISetState(@SW_HIDE, $GUIConnecting)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg

         Case $GUI_EVENT_CLOSE
            Exit

         Case $ButtonYes
            GUISetState(@SW_SHOW, $GUI2)
            GUISetState(@SW_SHOW, $ButtonEU)
            GUISetState(@SW_SHOW, $ButtonNA)
            GUISetState(@SW_SHOW, $ButtonAU)
            GUISetState(@SW_SHOW, $ButtonAS)
            GUISetState(@SW_SHOW, $ButtonAF)
            GUISetState(@SW_SHOW, $ButtonME)

         Case $ButtonUpL
            GUISetState(@SW_SHOW, $UpdGUI)

         Case $ButtonCloseUpd
            GUISetState(@SW_HIDE, $UpdGUI)

         Case $ButtonEU
            _PingFunc("google.ie")

         Case $ButtonNA
            _PingFunc("192.0.43.10")

         Case $ButtonAU
            _PingFunc("101.0.86.43")

         Case $ButtonAS
            _PingFunc("47.94.129.116")

         Case $ButtonSA
            _PingFunc("131.255.7.26")

         Case $ButtonAF
            _PingFunc("197.221.23.194")

         Case $ButtonME
            _PingFunc("185.229.226.83")

         Case $ButtonCan
            Exit
    EndSwitch
WEnd

Func _PingFunc($vPing, $iPingLimit = 250)
    GUISetState(@SW_SHOW, $GUIConnecting)
    GUISetState(@SW_SHOW, $LabelConn)
    Sleep(3000)
    Local $iPing = Ping($vPing, 250)
    If @error Then
        Switch @error
            Case 1
                MsgBox(4096, "Error","Host is offline.")

            Case 2
                MsgBox(4096, "Error","Host is unreachable")

            Case 3
                MsgBox(4096, "Error","Bad destination")

            Case 4
                MsgBox(4096, "Error","Other errors")

        EndSwitch
        Return
    EndIf
    If $iPing >= $iPingLimit Then
        MsgBox(4096, "Warning", "Your internet connection is unstable!" & @CRLF & "Internet connection speed: " & $iPing & "ms.")
        Msgbox(0,"SpeedTest","The IP/Website you connected to was: " & $vPing)
    Else
        MsgBox(4096, "SpeedTest", "Your internet connection is: " & $iPing & "ms.")
        Msgbox(0,"SpeedTest", "The IP/Website you connected to was: " & $vPing)
    EndIf
    GUISetState(@SW_HIDE, $GUIConnecting)
    GUISetState(@SW_HIDE, $LabelConn)
EndFunc

Yet again, I would like to thank everyone that contributes to helping me with this issue

Kind Regards,

Supra.

Share this post


Link to post
Share on other sites

Use GUIGetMsg() like GUIGetMsg($GUI_EVENT_ARRAY) so it returns an array; $aArray[0] contains event-/control ID and $aArray[1] window handle the event is from. Enables distinction between multiple GUI's.

https://www.autoitscript.com/autoit3/docs/functions/GUIGetMsg.htm

Share this post


Link to post
Share on other sites
27 minutes ago, Nine said:

$UpdGUILabel is too big.  Put height at 500, will work then. :)

I think that as days go by, I'm getting dumber and dumber...

Thanks so much :D

Share this post


Link to post
Share on other sites
1 hour ago, user4157124 said:

Use GUIGetMsg() like GUIGetMsg($GUI_EVENT_ARRAY) so it returns an array; $aArray[0] contains event-/control ID and $aArray[1] window handle the event is from. Enables distinction between multiple GUI's.

https://www.autoitscript.com/autoit3/docs/functions/GUIGetMsg.htm

It sounds complicated as hell because I  was working on work experience and I was working with Arrays. Believe me: Me + Arrays = are a bad thing but thanks for the reply!

Kind Regards,

Supra

Share this post


Link to post
Share on other sites
13 minutes ago, supraaxdd said:

I think that as days go by, I'm getting dumber and dumber...

Thanks so much :D

Nah, it is a common error not easy to find when you haven't gone though this before, now you know :bye:

Share this post


Link to post
Share on other sites
21 hours ago, Nine said:

Nah, it is a common error not easy to find when you haven't gone though this before, now you know :bye:

I guess :P Thank you :D

 

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By jannikrendl
      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
×
×
  • Create New...