website read timeout Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
DarkSider
Posts: 50
Joined: 29 May 2019, 11:06

website read timeout

28 Nov 2021, 16:14

Can somebody help me modify this a little bit please ? I need to include it in a file, and i'd like it if the file doesn't have access to the website (for let's say 30 seconds), the program to terminate.

Code: Select all

whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("GET", "https://www.autohotkey.com", true)
whr.Send(), whr.WaitForResponse(), version := whr.ResponseText
I did some tests but i think it's too complex for me :)
User avatar
mikeyww
Posts: 26882
Joined: 09 Sep 2014, 18:38

Re: website read timeout  Topic is solved

28 Nov 2021, 16:40

Possibly helpful, but I have not tested it thoroughly. At least it may be a lead for you.

viewtopic.php?p=264527#p264527

https://docs.microsoft.com/en-us/windows/win32/winhttp/iwinhttprequest-settimeouts

If it does generate an error after the timeout, you could probably use :arrow: Try to trap it.

This is a general example, but it might need adjustments.

Code: Select all

MsgBox % webGet("http://www.autohotkey.com")

webGet(url) {
 Try whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
 Catch
  Return
 whr.SetTimeouts(0, 30000, 30000, 600000)
 whr.Open("GET", url, False)
 Try {
  whr.Send()
  Sleep 100
  response := whr.ResponseText
 }
 Catch, err
  errMsg := "Problem:  " err.Extra
   . "`nFile:          " err.File
   . "`nLine:         " err.Line
   . "`n              " err.What
   . "`nError:                       " err.Message
 Return response
}
Others may have better ideas here.
DarkSider
Posts: 50
Joined: 29 May 2019, 11:06

Re: website read timeout

29 Nov 2021, 05:09

Thanks, just tested (some) of the functionality and does the job :)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Nerafius, RandomBoy and 189 guests