How to open a webpage with InPrivate?

Get help with using AutoHotkey and its commands and hotkeys
afe
Posts: 599
Joined: 06 Dec 2018, 04:36

How to open a webpage with InPrivate?

04 Oct 2019, 06:22

Hello,

I tried the following, but an Error: 0x80010108 error occurred.

Code: Select all

ie := ComObjCreate("InternetExplorer.Application")
ie.Visible := true
WinWait, % "ahk_id " ie.hwnd
PostMessage, 0x111, 0x8, 0,, % "ahk_id " ie.hwnd
WinClose
ie.Navigate("http://example.com/")
return
knoxastic
Posts: 4
Joined: 08 Oct 2019, 11:29

Re: How to open a webpage with InPrivate?

08 Oct 2019, 21:25

I don't know about the error you get, but I think there's no way to handle InPrivate windows from IE's objects. Here's a workaround that runs IE InPrivate mode and then uses ShellWindows to get the IE object.

Code: Select all

Run, iexplore.exe -private								; Run IE InPrivate mode

; Sleep 1000											; Wait for IE to finish loading

obj := ComObjCreate("Shell.Application").Windows		; Create a ShellWindows object to get the open windows

for window in obj {										; Look for IE's window
	if (window.Name = "Internet Explorer") {
		ie := window									; Get the InPrivate window
		break
	}
}

ie.Navigate("example.com")
I had to use the Sleep command because WinWait wasn't working and sometimes ShellWindows coulnd't get the IE window.
User avatar
Masonjar13
Posts: 1514
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: How to open a webpage with InPrivate?

08 Oct 2019, 22:24

This pretty much is exactly what knoxastic is doing, but in a more isolated manner. Unfortunately flashes the window though, I've never been able to get around that.
https://github.com/Masonjar13/AHK-Library/blob/master/Lib/IEObj.ahk

If you don't feel like dissecting it, here's an example to use the object.

Code: Select all

ie:=new IEObj
ie.init(1)
ie.navToUrl("http://example.com/")
And of course, you can always access the COM obj directly with ie.wb.
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, llgmesuris, Rohwedder and 56 guests