I am trying to use AutoHotKey v2. I get an error for WebRequest.Option(6) for an…
- User
I am trying to use AutoHotKey v2. I get an error for WebRequest.Option(6) for an invalided assignment when trying to set it to false. Here is the code:#Requires AutoHotkey v2.0 Req := Request("https://www.qobuz.com/us-en/search?q=grrexh0cewaeb") MsgBox(req.getAllResponseHeaders()) return
Request(url) { WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1") WebRequest.Option(6) := False ; No redirects WebRequest.Open("GET", url, false) WebRequest.Send() Return WebRequest }
- Assistant
In AutoHotkey v2, you should use the
Setmethod to change the WinHttpRequest's options. Here's the updated code:#Requires AutoHotkey v2.0 Req := Request("https://www.qobuz.com/us-en/search?q=grrexh0cewaeb") MsgBox(req.getAllResponseHeaders()) return Request(url) { WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1") WebRequest.Option(6).Set(False) ; No redirects WebRequest.Open("GET", url, false) WebRequest.Send() Return WebRequest }However, for AutoHotkey v2, it is recommended to use the built-in
HttpRequestandHttpOptionsobjects instead. Here's an example:#Requires AutoHotkey v2.0 Req := Request("https://www.qobuz.com/us-en/search?q=grrexh0cewaeb") MsgBox(Req.getAllResponseHeaders()) return Request(url) { WebRequest := HttpRequest.Open("GET", url) WebRequest.Options.MaxAutoRedirects := 0 ; No redirects WebRequest.Send() Return WebRequest }The second version uses the HttpRequest and HttpOptions objects, making it simpler to work with the Http settings. In this case, the MaxAutoRedirects property is set to 0, disabling automatic redirection.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.