youtuber Posted May 12, 2016 Share Posted May 12, 2016 How can I learn URLs status? Global $aURL = "https://www.autoitscript.com" Msgbox(0,"Status", "Status",_URLStatus($aURL)) Func _URLStatus($aURL) $objHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $objHTTP.Open("GET", $aURL, false) If $objHTTP.status = "200" Then Msgbox(0,"Connection", "ok") Else Msgbox(0,"Error", "Connection problem!") EndIf EndFunc Link to comment Share on other sites More sharing options...
Trong Posted May 13, 2016 Share Posted May 13, 2016 Global $aURL = "https://www.autoitscript.com" Local $urlStatus = _URLStatus($aURL) If $urlStatus <> 200 Then MsgBox(48, "Status", "Connection problem: " & $urlStatus & @CRLF & "URL: " & $aURL) Else MsgBox(32, "Status", "Connection Successful!" & @CRLF & "URL: " & $aURL) EndIf Func _URLStatus($aURL) $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("GET", $aURL, False) $oHTTP.Send() Return $oHTTP.Status = 200 EndFunc ;==>_URLStatus Regards, Link to comment Share on other sites More sharing options...
youtuber Posted May 13, 2016 Author Share Posted May 13, 2016 (edited) @Trong Thanks for trying, but I think there's a problem! Edited May 16, 2016 by youtuber Link to comment Share on other sites More sharing options...
Trong Posted May 13, 2016 Share Posted May 13, 2016 It only works when there is an Internet connection and active URL! I do not know how to ignore the error, I'm learning! Regards, Link to comment Share on other sites More sharing options...
youtuber Posted May 13, 2016 Author Share Posted May 13, 2016 (edited) @Trong Ok no problem thank you or for example : https://www.autoitscript.com/forum/topic/asdf If $urlStatus <> 404 Then ? Edited May 13, 2016 by youtuber Link to comment Share on other sites More sharing options...
Trong Posted May 13, 2016 Share Posted May 13, 2016 (edited) Global $aURL = "https://www.autoitscript.com/forum/topic/asdf" Local $urlStatus = _URLStatus($aURL) If @error Then MsgBox(48, "Error: " & @error, "Connection problem: " & $urlStatus & @CRLF & "URL: " & $aURL) Switch $urlStatus Case 200 MsgBox(32, "Status: " & $urlStatus, "Connection Successful!" & @CRLF & "URL: " & $aURL) Case 404 MsgBox(32, "Status: " & $urlStatus, "Connection Successful!" & @CRLF & "URL Not Found: " & $aURL) Case Else MsgBox(48, "Status: " & $urlStatus, "Connection problem!" & @CRLF & "URL: " & $aURL) EndSwitch Func _URLStatus($aURL) $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("HEAD", $aURL, False) If @error Then Return SetError(1, 0, 0) $oHTTP.Send() If @error Then Return SetError(2, 0, 0) Return $oHTTP.Status EndFunc ;==>_URLStatus Edited May 13, 2016 by Trong Regards, Link to comment Share on other sites More sharing options...
MichaelHB Posted May 13, 2016 Share Posted May 13, 2016 @Trong If you put a invalid URL it will give you a COM error, as advised by Mlipok, you should do something like this: expandcollapse popupLocal $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Local $sURL = "https://www.autoitscriptABCD.com/forum/topic/asdf" ; Deliberately cause error by using a non-existing URL For $i = 0 To 1 Local $urlStatus = _URLStatus($sURL) If @error Then MsgBox(48, "Error: " & @error, "Connection problem: " & $urlStatus & @CRLF & "URL: " & $sURL) Switch $urlStatus Case 200 MsgBox(32, "Status", "Connection Successful: " & $urlStatus & @CRLF & "URL: " & $sURL) Case 404 MsgBox(32, "Status", "Connection Successful: " & $urlStatus & @CRLF & "URL Not Found: " & $sURL) Case Else MsgBox(48, "Status", "Connection problem: " & $urlStatus & @CRLF & "URL: " & $sURL) EndSwitch $sURL = "http://www.google.com" ; Lets use a valid URL now Next Func _URLStatus($sURL) $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("HEAD", $sURL, False) If @error Then Return SetError(1, 0, 0) $oHTTP.Send() If @error Then Return SetError(2, 0, 0) Return $oHTTP.Status EndFunc ;==>_URLStatus Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc Exit By the way, its nice to see that you were seeking knowledge to be able to help someone else. youtuber and Trong 2 Link to comment Share on other sites More sharing options...
Trong Posted May 13, 2016 Share Posted May 13, 2016 (edited) Short final scripts: Global $oErrorHandler = ObjEvent("AutoIt.Error", "_COMErrFunc") Global $aURL = "https://www.autoitscriptA.com/forum/topic/aloha" Local $urlStatus = _URLStatus($aURL) Switch $urlStatus Case 200 MsgBox(32, "Status: " & $urlStatus, "Connection Successful!" & @CRLF & "URL: " & $aURL) Case 404 MsgBox(32, "Status: " & $urlStatus, "Connection Successful!" & @CRLF & "URL Not Found: " & $aURL) Case 105 MsgBox(48, "Status: " & $urlStatus, "Connection error: ERR_NAME_NOT_RESOLVED" & @CRLF & "URL is Not Found: " & $aURL) Case Else MsgBox(48, "Status: " & $urlStatus, "Connection error!" & @CRLF & "URL: " & $aURL) EndSwitch Func _URLStatus($aURL) $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("HEAD", $aURL, False) If @error Then Return SetError(1, 0, 0) $oHTTP.Send() If @error Then Return SetError(2, 0, 105) ;Error 105 (net::ERR_NAME_NOT_RESOLVED) Local $oStatus = $oHTTP.Status If @error Then Return SetError(3, 0, 118) ;Error 118 (net::ERR_CONNECTION_TIMED_OUT) ;~ $oErrorHandler = 0 Return $oStatus EndFunc ;==>_URLStatus Func _COMErrFunc() ; Do nothing special, just check @error after suspect functions. EndFunc ;==>_COMErrFunc Edited May 13, 2016 by Trong same time, duplicate! Regards, Link to comment Share on other sites More sharing options...
mLipok Posted May 13, 2016 Share Posted May 13, 2016 (edited) Why you mixing Local and Global statement at the same scope level ? Global $aURL = "https://www.autoitscriptA.com/forum/topic/aloha" Local $urlStatus = _URLStatus($aURL) Here is better example: expandcollapse popup#include <MsgBoxConstants.au3> _Example("https://www.somenotexistingurl.com") Func _Example($sURL) Local $sURL_Status = _ULRNotifier(_URL_CheckStatus($sURL)) If @error Then Return SetError(@error, @extended, $sURL_Status) MsgBox($MB_OK + $MB_ICONINFORMATION, 'SUCCESS', '$sURL_Status=' & $sURL_Status) EndFunc ;==>_Example Func _URL_CheckStatus($sURL) _URLChecker_COMErrDescripion("") Local $oErrorHandler = ObjEvent("AutoIt.Error", "_URLChecker_COMErrFunc") $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("HEAD", $sURL, False) If @error Then Return SetError(1, @error, 0) $oHTTP.Send() If @error Then Return SetError(2, @error, 105) ;Error 105 (net::ERR_NAME_NOT_RESOLVED) Local $sStatus = $oHTTP.Status If @error Then Return SetError(3, @error, 118) ;Error 118 (net::ERR_CONNECTION_TIMED_OUT) Return $sStatus EndFunc ;==>_URL_CheckStatus Func _URLChecker_COMErrFunc($oError) _URLChecker_COMErrDescripion($oError.description) Return ; you can comment/dlete this return to show full error descripition ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "$oError.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "$oError.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "$oError.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "$oError.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "$oError.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "$oError.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "$oError.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "$oError.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "$oError.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_URLChecker_COMErrFunc Func _URLChecker_COMErrDescripion($sDescription = Default) Local Static $sDescription_static = '' If $sDescription <> Default Then $sDescription_static = $sDescription Return $sDescription_static EndFunc ;==>_URLChecker_COMErrDescripion Func _ULRNotifier($vResult, $iError = @error, $iExtended = @extended) If $iError Then ConsoleWrite( _ "! @error = " & $iError & " @extended = " & $iExtended & " $vResult = " & $vResult & @CRLF & _ "! " & _URLChecker_COMErrDescripion() & @CRLF _ ) Return SetError($iError, $iExtended, $vResult) EndFunc ;==>_ULRNotifier Edited May 13, 2016 by mLipok youtuber 1 Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
Trong Posted May 13, 2016 Share Posted May 13, 2016 55 minutes ago, mLipok said: Why you mixing Local and Global statement at the same scope level ? Global $aURL = "https://www.autoitscriptA.com/forum/topic/aloha" Local $urlStatus = _URLStatus($aURL) better ? Global $oErrorHandler = ObjEvent("AutoIt.Error", "_COMErrFunc") Global $sURL = "https://www.autoitscriptA.com/forum/topic/aloha" Global $urlStatus = _URLStatus($sURL) Switch $urlStatus Case 200 MsgBox(32, "Status: " & $urlStatus, "Connection Successful!" & @CRLF & "URL: " & $sURL) Case 404 MsgBox(32, "Status: " & $urlStatus, "Connection Successful!" & @CRLF & "URL Not Found: " & $sURL) Case 105 MsgBox(48, "Status: " & $urlStatus, "Connection error: ERR_NAME_NOT_RESOLVED" & @CRLF & "URL is Not Found: " & $sURL) Case Else MsgBox(48, "Status: " & $urlStatus, "Connection error!" & @CRLF & "URL: " & $sURL) EndSwitch Func _URLStatus($aURL) Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("HEAD", $aURL, False) If @error Then Return SetError(1, @error, 0) $oHTTP.Send() If @error Then Return SetError(2, @error, 105) ;Error 105 (net::ERR_NAME_NOT_RESOLVED) Local $oStatus = $oHTTP.Status If @error Then Return SetError(3, @error, 118) ;Error 118 (net::ERR_CONNECTION_TIMED_OUT) ;~ $oErrorHandler = 0 Return $oStatus EndFunc ;==>_URLStatus Func _COMErrFunc() ; Do nothing special, just check @error after suspect functions. EndFunc ;==>_COMErrFunc Regards, Link to comment Share on other sites More sharing options...
mLipok Posted May 13, 2016 Share Posted May 13, 2016 11 minutes ago, Trong said: better ? Better is post #9 But the following one : expandcollapse popupOpt("MustDeclareVars", 1) #AutoIt3Wrapper_Run_AU3Check=Y #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #include <MsgBoxConstants.au3> _Example("https://www.somenotexistingurl.com") Func _Example($sURL) Local $sURL_Status = _ULRNotifier(_URL_CheckStatus($sURL)) If @error Then Return SetError(@error, @extended, $sURL_Status) MsgBox($MB_OK + $MB_ICONINFORMATION, 'SUCCESS', '$sURL_Status=' & $sURL_Status) EndFunc ;==>_Example Func _URL_CheckStatus($sURL) _URLChecker_COMErrDescripion("") Local $oErrorHandler = ObjEvent("AutoIt.Error", "_URLChecker_COMErrFunc") #forceref $oErrorHandler Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("HEAD", $sURL, False) If @error Then Return SetError(1, @error, '') $oHTTP.Send() Local $iError = @error Local $sStatus = $oHTTP.Status If @error Then Return SetError(3, @error, $sStatus) If $iError Then Return SetError(2, $iError, $sStatus) Return $sStatus EndFunc ;==>_URL_CheckStatus Func _URLChecker_COMErrFunc($oError) _URLChecker_COMErrDescripion($oError.description) Return ; you can comment/dlete this return to show full error descripition ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "$oError.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "$oError.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "$oError.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "$oError.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "$oError.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "$oError.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "$oError.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "$oError.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "$oError.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_URLChecker_COMErrFunc Func _URLChecker_COMErrDescripion($sDescription = Default) Local Static $sDescription_static = '' If $sDescription <> Default Then $sDescription_static = $sDescription Return $sDescription_static EndFunc ;==>_URLChecker_COMErrDescripion Func _ULRNotifier($vResult, $iError = @error, $iExtended = @extended) If $iError Then ConsoleWrite( _ "! @error = " & $iError & " @extended = " & $iExtended & " $vResult = " & $vResult & @CRLF & _ "! " & _URLChecker_COMErrDescripion() & @CRLF _ ) Return SetError($iError, $iExtended, $vResult) EndFunc ;==>_ULRNotifier is the best - at least for the moment when I post it youtuber and MichaelHB 2 Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
youtuber Posted May 22, 2016 Author Share Posted May 22, 2016 (edited) Is it true my code accordingly? expandcollapse popup#include <Inet.au3> #include <String.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $oErrorHandler = ObjEvent("AutoIt.Error", "_COMErrFunc") Global $sURL = "https://www.google.com" Global $urlStatus = _URLStatus($sURL) #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 452, 282, 33, 105) $Edit1 = GUICtrlCreateEdit("", 32, 32, 185, 241) GUICtrlSetData(-1, "") $Button1 = GUICtrlCreateButton("Run", 320, 16, 75, 25) $Edit2 = GUICtrlCreateEdit("", 232, 88, 169, 177) GUICtrlSetData(-1, "") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $aproxyread = StringSplit(GUICtrlRead($Edit1), @CR) For $aproxyadd = 1 To UBound($aproxyread) - 1 Sleep(800) HttpSetProxy(2, $aproxyread[$aproxyadd]) Switch $urlStatus Case 200 GUICtrlSetData($Edit2, "Proxy: " & $aproxyread[$aproxyadd] & @CRLF & "IP: " & _IPGet()) Case Else HttpSetProxy(2, $aproxyread[$aproxyadd], @CR) GUICtrlSetData($Edit2, "Proxy: " & $aproxyread[$aproxyadd] & @CRLF & "IP: " & _IPGet()) EndSwitch Next EndSwitch WEnd Func _IPGet() Local Const $GETIP_TIMER = 3000 Local Static $hTimer = 0 Local Static $sLastIP = 0 If TimerDiff($hTimer) < $GETIP_TIMER And Not $sLastIP Then Return SetExtended(1, $sLastIP) EndIf Local $aGetIPURL[] = ["http://bot.whatismyipaddress.com", "http://www.myexternalip.com/raw", "http://checkip.dyndns.org"], $aReturn = 0, $sReturn = "" For $i = 1 To UBound($aGetIPURL) - 1 $sReturn = InetRead($aGetIPURL[$i]) If @error Or $sReturn == "" Then ContinueLoop $aReturn = StringRegExp(BinaryToString($sReturn), "((?:\d{1,3}\.){3}\d{1,3})", 3) If Not @error Then $sReturn = $aReturn[0] ExitLoop EndIf $sReturn = "" Next $hTimer = TimerInit() $sLastIP = $sReturn If $sReturn == "" Then Return SetError(1, 0, -1) Return $sReturn EndFunc ;==>_IPGet Func _URLStatus($aURL) Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("HEAD", $aURL, False) If @error Then Return SetError(1, @error, 0) $oHTTP.Send() If @error Then Return SetError(2, @error, 105) ;Error 105 (net::ERR_NAME_NOT_RESOLVED) Local $oStatus = $oHTTP.Status If @error Then Return SetError(3, @error, 118) ;Error 118 (net::ERR_CONNECTION_TIMED_OUT) ;~ $oErrorHandler = 0 Return $oStatus EndFunc ;==>_URLStatus Func _COMErrFunc() ; Do nothing special, just check @error after suspect functions. EndFunc ;==>_COMErrFunc <snip> Edited May 27, 2016 by JLogan3o13 Link to comment Share on other sites More sharing options...
youtuber Posted May 26, 2016 Author Share Posted May 26, 2016 (edited) Help please if The proxy does not work skip the lineHow? Case $Button1 $aproxyread = StringSplit(GUICtrlRead($Edit1), @CR) For $aproxyadd = 1 To UBound($aproxyread) - 1 Sleep(800) HttpSetProxy(2, $aproxyread[$aproxyadd]) Switch $urlStatus Case 200 GUICtrlSetData($Edit2, "Proxy: " & $aproxyread[$aproxyadd] & @CRLF & "IP: " & _IPGet()) ;------------------------------------------------------------------------------------ Case Else HttpSetProxy(2, $aproxyread[$aproxyadd], @CR);Is this the correct code to bypass the proxy? Edited May 26, 2016 by youtuber Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 27, 2016 Moderators Share Posted May 27, 2016 @youtuber please upload your text file again if you intended it to be in the post, the link became corrupted. youtuber 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
youtuber Posted May 27, 2016 Author Share Posted May 27, 2016 @JLogan3o13 thanks for your answer again this file proxylist.txt Link to comment Share on other sites More sharing options...
Trong Posted May 28, 2016 Share Posted May 28, 2016 Don't PM for ask or request help! All problem, please post here! expandcollapse popup#include <Inet.au3> #include <String.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $oErrorHandler = ObjEvent("AutoIt.Error", "_COMErrFunc") Global $sURL = "https://www.google.com" Global $sListProxy, $sIP #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Form1", 452, 282, 33, 105) Global $Edit1 = GUICtrlCreateEdit("", 32, 32, 185, 241) GUICtrlSetData(-1, "") Global $Button1 = GUICtrlCreateButton("Run", 320, 16, 75, 25) Global $Edit2 = GUICtrlCreateEdit("", 232, 88, 169, 177) GUICtrlSetData(-1, "") Global $Label1 = GUICtrlCreateLabel("", 232, 64, 164, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $sListProxy = "" $aproxyread = StringSplit(GUICtrlRead($Edit1), @CR) For $aproxyadd = 1 To UBound($aproxyread) - 1 GUICtrlSetData($Label1, "Set Proxy: " & $aproxyread[$aproxyadd]) HttpSetProxy(2, $aproxyread[$aproxyadd]) If _URLStatus($sURL) = 200 Then GUICtrlSetData($Label1, "Getting IP......") $sIP = _IPGet() If StringInStr($sIP, ".") Then GUICtrlSetData($Label1, "Get IP sucsses!") $sListProxy &= "Proxy: " & $aproxyread[$aproxyadd] & @CRLF & "Cur IP: " & $sIP & @CRLF & @CRLF GUICtrlSetData($Edit2, $sListProxy) EndIf Sleep(500) GUICtrlSetData($Label1, "") Next EndSwitch WEnd Func _IPGet() Local $aGetIPURL[] = ["http://www.myexternalip.com/raw", "http://bot.whatismyipaddress.com", "http://checkip.dyndns.org"], $aReturn = 0, $sReturn = "" For $i = 1 To UBound($aGetIPURL) - 1 $sReturn = InetRead($aGetIPURL[$i]) If @error Or $sReturn == "" Then ContinueLoop $aReturn = StringRegExp(BinaryToString($sReturn), "((?:\d{1,3}\.){3}\d{1,3})", 3) If Not @error Then $sReturn = $aReturn[0] ExitLoop EndIf $sReturn = "" Next If $sReturn == "" Then Return SetError(1, 0, -1) Return $sReturn EndFunc ;==>_IPGet Func _URLStatus($aURL) Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("HEAD", $aURL, False) If @error Then Return SetError(1, @error, 0) $oHTTP.Send() If @error Then Return SetError(2, @error, 105) ;Error 105 (net::ERR_NAME_NOT_RESOLVED) Local $oStatus = $oHTTP.Status If @error Then Return SetError(3, @error, 118) ;Error 118 (net::ERR_CONNECTION_TIMED_OUT) ;~ $oErrorHandler = 0 Return $oStatus EndFunc ;==>_URLStatus Func _COMErrFunc() ; Do nothing special, just check @error after suspect functions. EndFunc ;==>_COMErrFunc If only check Proxy, use this function: TCPStartup() OnAutoItExitRegister("TCPShutdown") Func _CheckProxy($iProxy) If Not StringInStr($iProxy, ":") Then Return SetError(1, 0, 0) Local $iSocket = 0, $xSocket = StringSplit($iProxy, ":", 1) If IsArray($xSocket) Then If $xSocket[0] = 2 Then $iSocket = TCPConnect($xSocket[1], $xSocket[2]) If Not @error Then TCPCloseSocket($iSocket) Return 1 EndIf EndIf EndIf Return 0 EndFunc ;==>_CheckProxy Regards, 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