Page 1 of 1

responseText

Posted: 15 May 2021, 14:01
by maskeli
here's my code guys.

Code: Select all

whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("GET", "https drive.google.com /uc?id=1iA2yEkOOlbfYjEEQy0leOk5y2BGx0mDL&export=download",  Broken Link for safety true)
whr.Send()
whr.WaitForResponse()
RegExMatch(whr.ResponseText, "gun(\d+) ay(\d+) yil(\d+)", sure)
msgbox hey
whr.Open("GET", "http worldtimeapi.org /api/timezone/Europe/Istanbul.txt",  Broken Link for safety true)
whr.Send()
whr.WaitForResponse()
RegExMatch(whr.ResponseText, "datetime: (\d+)-(\d+)-(\d+)T", saat)
when i shutdown the internet connection i get this error :
how can i fix this

Re: responseText

Posted: 15 May 2021, 14:41
by mikeyww
You can use the Try command to avoid throwing an error.

Re: responseText

Posted: 16 May 2021, 04:41
by ananthuthilakan
and then you may use https://www.autohotkey.com/docs/commands/Catch.htm to do something else
for example show a internet error msg box

Code: Select all

try
{
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("GET", "https drive.google.com /uc?id=1iA2yEkOOlbfYjEEQy0leOk5y2BGx0mDL&export=download",  Broken Link for safety true)
whr.Send()
whr.WaitForResponse()
RegExMatch(whr.ResponseText, "gun(\d+) ay(\d+) yil(\d+)", sure)
msgbox hey
whr.Open("GET", "http worldtimeapi.org /api/timezone/Europe/Istanbul.txt",  Broken Link for safety true)
whr.Send()
whr.WaitForResponse()
RegExMatch(whr.ResponseText, "datetime: (\d+)-(\d+)-(\d+)T", saat)

}
catch e  ; Handles the first error/exception raised by the block above.
{
		
		Sleep, 1000
		msgbox,NO INTERNET, NO INTERNET`n EXITING......
		ExitApp
   
}