Unexpected behavior when attempting to set WinHttp.WinHttpRequest.5.1 options Topic is solved

Discuss the future of the AutoHotkey language
micasa
Posts: 15
Joined: 29 Dec 2018, 04:21

Unexpected behavior when attempting to set WinHttp.WinHttpRequest.5.1 options

05 Feb 2019, 10:02

Hello, everyone.

I am new to AHK, in general, so this might not be a bug at all, but the behavior seems a bit unexpected to me.

WinHttp.WinHttpRequest.5.1 provides various options that can be set. Here is the reference:

https://docs.microsoft.com/en-us/windows/desktop/winhttp/winhttprequestoption

In AHK V1, it is possible to set WinHttp.WinHttpRequest.5.1 options using variable assignment.

For example we can disable automatic redirects like this:

Code: Select all

HttpObj.Option(6) := False
However, when I try to run this code in AHK V2, it throws an error:

Code: Select all

Error: Invalid assignment.

Specifically: := False
I have tried various ways to change this option, including

Code: Select all

HttpObj.Option(6) := False
HttpObj.Option(6) := "False"
HttpObj.Option(6) := 0
HttpObj.Option(6, False)
HttpObj.Option(6, "False")
HttpObj.Option(6, 0)
I even tried some combinations based on the C++ typedef, but nothing seems to work.

Does anyone know how to set these options in AHK V2? If yes, please let me know.

Thank you for your valuable time.
User avatar
nnnik
Posts: 3881
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: Unexpected behavior when attempting to set WinHttp.WinHttpRequest.5.1 options  Topic is solved

05 Feb 2019, 10:18

You need to use [] instead of (). The () were allowed for no good reason and are actually wrong.
Recommends AHK Studio
micasa
Posts: 15
Joined: 29 Dec 2018, 04:21

Re: Unexpected behavior when attempting to set WinHttp.WinHttpRequest.5.1 options

05 Feb 2019, 10:23

nnnik wrote:
05 Feb 2019, 10:18
You need to use [] instead of (). The () were allowed for no good reason and are actually wrong.
Thank you very much! Actually, I was thinking that, but when I tried some array methods on HttpObj.Option I was getting errors, so I wrongly assumed [] would not work.

Thanks again for your help and quick reply!

Return to “AutoHotkey v2 Development”

Who is online

Users browsing this forum: Google [Bot] and 6 guests