Since I know that the examples thread isn't a place for help and support and the answers I got there didn't quite help me figure out what I'm doing wrong, I'll post here. (Thanks, trancexx, for clearing some things up though.)
I've got a form that I'm trying to fill on a secure site, but it's located in a Javascript redirect, so I don't know how to get WinHttp to find the form. The code below just gives me @error 1.
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <WinHttp.au3> Opt("TrayIconDebug", 1) Opt("MustDeclareVars", 1) Global $aError[7] = ["", "No forms on the page", "Invalid form", "No forms with specified attributes on the page", "Connection problems", "Action is invalid", "Invalid session handle passed"] Global $hOpen = _WinHttpOpen() Global $hConnect = _WinHttpConnect($hOpen, "www.bcwebtrack.com", $INTERNET_DEFAULT_HTTPS_PORT) Global $sUser = "MyUser" Global $sPass = "MyPass" Global $sRead = _WinHttpSimpleFormFill($hConnect, "/webtrack/index.php", "name:LoginForm", "UserId", $sUser, "Password", $sPass, "CompanyId", $sUser) If @error Then MsgBox(0, "Form Fill Error", $aError[@error]) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) If $sRead Then ConsoleWrite($sRead & @CRLF)
The following code will give me the source with the forms:
Global $hRequest = _WinHttpOpenRequest($hConnect, "POST", "/webtrack/index.php", Default, Default, Default, $WINHTTP_FLAG_SECURE) _WinHttpSendRequest($hRequest) _WinHttpReceiveResponse($hRequest) If _WinHttpQueryDataAvailable($hRequest) Then Global $sHTML Do $sHTML &= _WinHttpReadData($hRequest) ;Read HTTP data (source code) Until @error EndIf
Any and all help would be very much appreciated, please and thank you.