supraaxdd Posted March 16, 2019 Share Posted March 16, 2019 Hello! This time I am turning to you guys as the community to help me out with this problem that I have because the program declares an error code 0 and closes the program immediately after clicking the Proceed button (EU IS THE ONLY OPTION THAT WORKS). I made a function that reads the combo box and if the option stated in the func are = to each other, it would use the _PingFunc. Here is the code: expandcollapse popup#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 & @CR & @CR & "Update Log for v1.0.4" & @CR & @CR & "- Fixed the Error UI closing the whole program.", 40, 30, 400, 500) $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) $DropGUIEU = GUICreate("Europe", 200, 100, -1, -1) $DropEU = GUICtrlCreateCombo(" - Please select an option -", 10, 15, 180, 15) $CancelEU = GUICtrlCreateButton("Cancel", 110, 65, 80, 25) $ProceedEU = GUICtrlCreateButton("Proceed", 10, 65, 80, 25) $DropGUINA = GUICreate("North America", 200, 100, -1, -1) $DropNA = GUICtrlCreateCombo(" - Please select an option -", 10, 15, 180, 15) $CancelNA = GUICtrlCreateButton("Cancel", 110, 65, 80, 25) $ProceedNA = GUICtrlCreateButton("Proceed", 10, 65, 80, 25) $DropGUIAU = GUICreate("Australia", 200, 100, -1, -1) $DropAU = GUICtrlCreateCombo(" - Please select an option -", 10, 15, 180, 15) $CancelAU = GUICtrlCreateButton("Cancel", 110, 65, 80, 25) $ProceedAU = GUICtrlCreateButton("Proceed", 10, 65, 80, 25) $DropGUIAS = GUICreate("Asia", 200, 100, -1, -1) $DropAS = GUICtrlCreateCombo(" - Please select an option -", 10, 15, 180, 15) $CancelAS = GUICtrlCreateButton("Cancel", 110, 65, 80, 25) $ProceedAS = GUICtrlCreateButton("Proceed", 10, 65, 80, 25) $DropGUISA = GUICreate("South America", 200, 100, -1, -1) $DropSA = GUICtrlCreateCombo(" - Please select an option -", 10, 15, 180, 15) $CancelSA = GUICtrlCreateButton("Cancel", 110, 65, 80, 25) $ProceedSA = GUICtrlCreateButton("Proceed", 10, 65, 80, 25) $DropGUIAF = GUICreate("South Africa", 200, 100, -1, -1) $DropAF = GUICtrlCreateCombo(" - Please select an option -", 10, 15, 180, 15) $CancelAF = GUICtrlCreateButton("Cancel", 110, 65, 80, 25) $ProceedAF = GUICtrlCreateButton("Proceed", 10, 65, 80, 25) $DropGUIME = GUICreate("Middle East", 200, 100, -1, -1) $DropME = GUICtrlCreateCombo(" - Please select an option -", 10, 15, 180, 15) $CancelME = GUICtrlCreateButton("Cancel", 110, 65, 80, 25) $ProceedME = GUICtrlCreateButton("Proceed", 10, 65, 80, 25) ;~ --------------------------------------------------------------------------- $GUIConnecting = GUICreate("Connecting...",200,100,-1,-1) $LabelConn = GUICtrlCreateLabel("Connecting..." ,40, 50, 400, 20) ;~ ---------------------------------------------------------------------------- $GUIErrOne = GUICreate("Error", 200, 150, -1, -1) $LabelErrOne = GUICtrlCreateLabel("Host is offline.", 50, 50, 200, 15) $BackToMain1 = GUICtrlCreateButton("Close", 110, 110, 80, 30) ;~ --------------------------------------------------------------------------- $GUIErrTwo = GUICreate("Error", 200, 150, -1, -1) $LabelErrTwo = GUICtrlCreateLabel("Host is unreachable.", 50, 50, 200, 15) $BackToMain2 = GUICtrlCreateButton("Close", 110, 110, 80, 30) ;~ --------------------------------------------------------------------------- $GUIErrThree = GUICreate("Error", 200, 150, -1, -1) $LabelErrThree = GUICtrlCreateLabel("Bad destination.", 50, 50, 200, 15) $BackToMain3 = GUICtrlCreateButton("Close", 110, 110, 80, 30) ;~ -------------------------------------------------------------------------- $GUIErrFour = GUICreate("Error", 200, 150, -1, -1) $LabelErrFour = GUICtrlCreateLabel("Other errors.", 50, 50, 200, 15) $BackToMain4 = GUICtrlCreateButton("Close", 110, 110, 80, 30) 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, $DropGUIEU) GUISetState(@SW_HIDE, $DropGUINA) GUISetState(@SW_HIDE, $DropGUIAU) GUISetState(@SW_HIDE, $DropGUIAS) GUISetState(@SW_HIDE, $DropGUISA) GUISetState(@SW_HIDE, $DropGUIAF) GUISetState(@SW_HIDE, $DropGUIME) GUISetState(@SW_HIDE, $GUIConnecting) GUISetState(@SW_HIDE, $GUIErrOne) GUISetState(@SW_HIDE, $GUIErrTwo) GUISetState(@SW_HIDE, $GUIErrThree) GUISetState(@SW_HIDE, $GUIErrFour) GUISetState(@SW_HIDE, $LabelErrOne) GUISetState(@SW_HIDE, $LabelErrTwo) GUISetState(@SW_HIDE, $LabelErrThree) GUISetState(@SW_HIDE, $LabelErrFour) GUISetState(@SW_HIDE, $BackToMain1) GUISetState(@SW_HIDE, $BackToMain2) GUISetState(@SW_HIDE, $BackToMain3) GUISetState(@SW_HIDE, $BackToMain4) ;~ ---------------------------------------------------------------------------------------------- $DropOpt = "" $Option = "" ;~ ---------------------------------------------------------------------------------------------- GUICtrlSetData($DropEU, "Ireland", " - Please select an option -") GUICtrlSetData($DropNA, "Central US", " - Please select an option -") GUICtrlSetData($DropAU, "Sydney", " - Please select an option -") GUICtrlSetData($DropAS, "Bejing", " - Please select an option -") GUICtrlSetData($DropSA, "Buenos Aires", " - Please select an option -") GUICtrlSetData($DropAF, "Johannesburg", " - Please select an option -") GUICtrlSetData($DropME, "Tel-Aviv", " - Please select an option -") #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 GUISetState(@SW_SHOW, $DropGUIEU) GUISetState(@SW_SHOW, $DropEU) Case $CancelEU GUISetState(@SW_HIDE, $DropGUIEU) Case $ProceedEU DropRead($DropEU) Case $ButtonNA GUISetState(@SW_SHOW, $DropGUINA) GUISetState(@SW_SHOW, $DropNA) Case $CancelNA GUISetState(@SW_HIDE, $DropGUINA) Case $ButtonAU GUISetState(@SW_SHOW, $DropGUIAU) GUISetState(@SW_SHOW, $DropAU) Case $CancelAU GUISetState(@SW_HIDE, $DropGUIAU) Case $ButtonAS GUISetState(@SW_SHOW, $DropGUIAS) GUISetState(@SW_SHOW, $DropAS) Case $CancelAS GUISetState(@SW_HIDE, $DropGUIAS) Case $ButtonSA GUISetState(@SW_SHOW, $DropGUISA) GUISetState(@SW_SHOW, $DropSA) Case $CancelSA GUISetState(@SW_HIDE, $DropGUISA) Case $ButtonAF GUISetState(@SW_SHOW, $DropGUIAF) GUISetState(@SW_SHOW, $DropAF) Case $CancelAF GUISetState(@SW_HIDE, $DropGUIAF) Case $ButtonME GUISetState(@SW_SHOW, $DropGUIME) GUISetState(@SW_SHOW, $DropME) Case $CancelME GUISetState(@SW_HIDE, $DropGUIME) Case $BackToMain1 GUISetState(@SW_HIDE, $GUIErrOne) Case $BackToMain2 GUISetState(@SW_HIDE, $GUIErrTwo) Case $BackToMain3 GUISetState(@SW_HIDE, $GUIErrThree) Case $BackToMain4 GUISetState(@SW_HIDE, $GUIErrFour) 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 GUISetState(@SW_SHOW, $GUIErrOne) GUISetState(@SW_SHOW, $LabelErrOne) GUISetState(@SW_SHOW, $BackToMain1) GUISetState(@SW_HIDE, $GUIConnecting) Case 2 GUISetState(@SW_SHOW, $GUIErrTwo) GUISetState(@SW_SHOW, $LabelErrTwo) GUISetState(@SW_SHOW, $BackToMain2) GUISetState(@SW_HIDE, $GUIConnecting) Case 3 GUISetState(@SW_SHOW, $GUIErrThree) GUISetState(@SW_SHOW, $LabelErrThree) GUISetState(@SW_SHOW, $BackToMain3) GUISetState(@SW_HIDE, $GUIConnecting) Case 4 GUISetState(@SW_SHOW, $GUIErrFour) GUISetState(@SW_SHOW, $LabelErrFour) GUISetState(@SW_SHOW, $BackToMain4) GUISetState(@SW_HIDE, $GUIConnecting) 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 Func DropRead($Option) If $Option = $DropEU then GUICtrlRead($DropOpt) If $DropOpt = "Ireland" Then _PingFunc("google.ie") EndIf EndIf I would really appreciate it if a member of this fantastic community helps. Kind Regards, Supra Link to comment Share on other sites More sharing options...
Developers Jos Posted March 16, 2019 Developers Share Posted March 16, 2019 Just a quick glace at it, but you only have a case for $ProceedEU and none of the other $Proceed?? variables? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
supraaxdd Posted March 16, 2019 Author Share Posted March 16, 2019 Just now, Jos said: Just a quick glace at it, but you only have a case for $ProceedEU and none of the other $Proceed?? variables? Jos I mentioned at the start that only EU works because I didn't implement the Proceed in any other button just yet. I first expeirment with one button and if I get it right, I do it to all others. Kind Regards, Supra Link to comment Share on other sites More sharing options...
Developers Jos Posted March 16, 2019 Developers Share Posted March 16, 2019 Ok, a simple debug line revealed your issue(s) in the DropRead() Func and changed it to this to continue with the ping(): Func DropRead($Option) If $Option = $DropEU Then $sel = GUICtrlRead($Option) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sel = ' & $sel & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console If $sel = "Ireland" Then _PingFunc("google.ie") EndIf EndIf EndFunc ;==>DropRead Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
supraaxdd Posted March 16, 2019 Author Share Posted March 16, 2019 5 minutes ago, Jos said: Ok, a simple debug line revealed your issue(s) in the DropRead() Func and changed it to this to continue with the ping(): Func DropRead($Option) If $Option = $DropEU Then $sel = GUICtrlRead($Option) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sel = ' & $sel & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console If $sel = "Ireland" Then _PingFunc("google.ie") EndIf EndIf EndFunc ;==>DropRead Jos May I ask, how does this debug work, I'm really new to this and I want this to be sucessful and I want to try the best as I can. This is also an opportunity for me to learn. Kind Regards, Supra Link to comment Share on other sites More sharing options...
Developers Jos Posted March 16, 2019 Developers Share Posted March 16, 2019 I assume you will be using SciTE and you have installed the full SciTE4AutoIt3! Just put the cursor on the variable you want to check and hit alt+d. This will insert an consolewrite statement which then will display the requested value in the SciTE output pane when it gets to that spot. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
supraaxdd Posted March 16, 2019 Author Share Posted March 16, 2019 31 minutes ago, Jos said: I assume you will be using SciTE and you have installed the full SciTE4AutoIt3! Just put the cursor on the variable you want to check and hit alt+d. This will insert an consolewrite statement which then will display the requested value in the SciTE output pane when it gets to that spot. Jos I will let you know how it will work for me, and yes, I'm using SciTE Regards, Supra Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now