Reputation: 51
$url = "https://190.198.14.15/"
$formID = ""
$formUID = "username"
$uName = "admin"
$formPID = "password"
$pwd = "SeR^ER@iL0"
$formSubmit = "ID_LOGON"
;Launch the Internet Explorer as a private session
ShellExecute ("iexplore.exe", " -private about:blank", @programFilesDir & "\Internet Explorer\iexplore.exe", "open", @SW_MAXIMIZE)
WinWait ("Blank Page")
$oIE = _IEAttach ("about:blank", "url")
;Wait for the IE to launch
_IELoadWait ($oIE)
;Navigate to the given URL
_IENavigate ($oIE, $url)
;Get the IE process id specific to this instance
Local $PID = WinGetProcess(_IEPropertyGet($oIE, "hwnd"))
;Print the PID in the console
If $PID Then
;MsgBox(0, "Example", "Internet Explorer is running.")
;MsgBox(0,"Process ID",$PID)
ConsoleWrite("["&$PID&"]")
Else
MsgBox(0, "Example", "Unable to get the process id of IE instance")
EndIf
;Disable IE address bar and menu bar
_IEPropertySet ($oIE, "addressbar", False)
_IEPropertySet ($oIE, "menubar", False)
;Click on 'Continue to this website' option if there is any HTTPS certificate Warning
while(_IELinkClickByText ($oIE, "Continue to this website (not recommended)."))
_IELoadWait ($oIE,10000)
wend
;Get the field id and fill with provided value
;$oIE.document.getElementById($formUID).value = $uName
$oIE.document.getElementsByName($formUID).Item(0).value = $uName
$oIE.document.getElementById($formPID).value = $pwd
;$oSubmit = _IEGetObjByName ($oIE, $formSubmit)
$oSubmit = $oIE.document.getElementById($formSubmit)
_IEAction ($oSubmit, "click")
Where formUID=username textbox id, uname=username, formPID=password box id, pwd=password, formSubmit=submit button id.
One more problem is this entire html page is developed with form tag. The same code will work with other from which are developed with form tags even in IE10 and windows 8.
Upvotes: 0
Views: 579
Reputation: 2946
Using _IECreateEmbedded will make IE work in compatibility mode (IE8).
If thats now what you need, you can run this code once and then all IE instances will run in compatibility mode.
$64Bit = ""
If @OSArch = "X64" Then
$64Bit = "64"
EndIf
If StringLeft(RegRead("HKLM" & $64Bit & "\SOFTWARE\Microsoft\Internet Explorer\Version Vector", "IE"), 1) > 8 Then ;Check for version 9 or later
$wshNetwork = ObjCreate("WScript.Network")
$struser = $wshNetwork.Username
$objWMIService = ObjGet("winmgmts:\\.\root\cimv2")
$objAccount = $objWMIService.Get('Win32_UserAccount.Name="' & $struser & '",Domain="' & @ComputerName & '"')
RegWrite("HKU" & $64Bit & "\" & $objAccount.SID & "\Software\Microsoft\Internet Explorer\BrowserEmulation\", "AllSitesCompatibilityMode", "REG_DWORD", 1)
RegWrite("HKU\" & $objAccount.SID & "\Software\Microsoft\Internet Explorer\BrowserEmulation\", "AllSitesCompatibilityMode", "REG_DWORD", 1)
EndIf
Upvotes: 1