Jump to content

_IECreate() in private browsing mode??


Recommended Posts

4 minutes ago, Danp2 said:

Maybe this thread will help you.

 

in my app I need to open a page in _IECreate() then close then re-open

is there anyway to edit IE.au3 to add -private parameter ??

Edited by AlienStar
Link to comment
Share on other sites

Try this one :

#Include <IE.au3>

$oIE = _IECreatePrivate("http://www.autoitscript.com")


Func _IECreatePrivate($sUrl = "about:blank", $iWait = 1)
    Local $sPFDir = (StringInStr(@OSArch, "64") AND Not @AutoItX64) ? RegRead("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir") : @ProgramFilesDir
    ShellExecute ($sPFDir & "\Internet Explorer\iexplore.exe", "-noframemerging -private " & $sUrl, @ProgramFilesDir & "\Internet Explorer")
    Local $hPrivateIE = WinWaitActive("[REGEXPTITLE:.+\[InPrivate\]]", "", 3)
    If Not $hPrivateIE Then Return SetError(1, 0, 0)
    Local $oPrivateIE = _IEAttach($hPrivateIE, "hwnd")
    If @error Then Return SetError(2, 0, 0)
    If $iWait Then _IELoadWait($oPrivateIE)
    Return $oPrivateIE
EndFunc

 

Link to comment
Share on other sites

4 hours ago, jguinch said:

Try this one :

#Include <IE.au3>

$oIE = _IECreatePrivate("http://www.autoitscript.com")


Func _IECreatePrivate($sUrl = "about:blank", $iWait = 1)
    Local $sPFDir = (StringInStr(@OSArch, "64") AND Not @AutoItX64) ? RegRead("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir") : @ProgramFilesDir
    ShellExecute ($sPFDir & "\Internet Explorer\iexplore.exe", "-noframemerging -private " & $sUrl, @ProgramFilesDir & "\Internet Explorer")
    Local $hPrivateIE = WinWaitActive("[REGEXPTITLE:.+\[InPrivate\]]", "", 3)
    If Not $hPrivateIE Then Return SetError(1, 0, 0)
    Local $oPrivateIE = _IEAttach($hPrivateIE, "hwnd")
    If @error Then Return SetError(2, 0, 0)
    If $iWait Then _IELoadWait($oPrivateIE)
    Return $oPrivateIE
EndFunc

 

thanks so much :) it works fine but I can't use other IE functions according to  this function

_IECreatePrivate

I need to use :

_IEDocReadHTML($oIE)
_IELoadWait($oIE)

they don't work

Edited by AlienStar
Link to comment
Share on other sites

4 hours ago, jguinch said:

Please, show your code...

Local $oIE = _IECreate("https://twitter.com/login?username_or_email=xxxxx")
while _IELoadWait($oIE)=false
    Sleep(100)
wend
Send("{TAB}")
$password = xxxxxxxxx
Send($password)
Send("{ENTER}")
Local $sHTML = _IEDocReadHTML($oIE)
MsgBox(0,"content ",$sHTML)

 

Edited by AlienStar
Link to comment
Share on other sites

  • 1 year later...
On 10/9/2017 at 10:23 AM, jguinch said:

Try this one :

#Include <IE.au3>

$oIE = _IECreatePrivate("http://www.autoitscript.com")


Func _IECreatePrivate($sUrl = "about:blank", $iWait = 1)
    Local $sPFDir = (StringInStr(@OSArch, "64") AND Not @AutoItX64) ? RegRead("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir") : @ProgramFilesDir
    ShellExecute ($sPFDir & "\Internet Explorer\iexplore.exe", "-noframemerging -private " & $sUrl, @ProgramFilesDir & "\Internet Explorer")
    Local $hPrivateIE = WinWaitActive("[REGEXPTITLE:.+\[InPrivate\]]", "", 3)
    If Not $hPrivateIE Then Return SetError(1, 0, 0)
    Local $oPrivateIE = _IEAttach($hPrivateIE, "hwnd")
    If @error Then Return SetError(2, 0, 0)
    If $iWait Then _IELoadWait($oPrivateIE)
    Return $oPrivateIE
EndFunc

 

Hi, sorry to bring up an old thread, but this is the best "IECreatePrivate" function I've found. It works quite well, but for some reason I cannot control $oIE afterwards. Are you still around to help?

Link to comment
Share on other sites

If you look at scite console, you can see that the _IEAttach gives a warning  Hence, SetError is returned, not the object.  But if you add a small delay before it will work.

#Include <IE.au3>

$oIE = _IECreatePrivate("http://www.autoitscript.com")
If @error Then MsgBox ($MB_SYSTEMMODAL,"","Error")

Func _IECreatePrivate($sUrl = "about:blank", $iWait = 1)
    Local $sPFDir = (StringInStr(@OSArch, "64") AND Not @AutoItX64) ? RegRead("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir") : @ProgramFilesDir
    ShellExecute ($sPFDir & "\Internet Explorer\iexplore.exe", "-noframemerging -private " & $sUrl, @ProgramFilesDir & "\Internet Explorer")
    Local $hPrivateIE = WinWaitActive("[REGEXPTITLE:.+\[InPrivate\]]", "", 10)
    If Not $hPrivateIE Then Return SetError(1, 0, 0)
    Sleep (1000)
    Local $oPrivateIE = _IEAttach($hPrivateIE, "hwnd")
    If @error Then Return SetError(2, 0, 0)
    If $iWait Then _IELoadWait($oPrivateIE)
    Return $oPrivateIE
EndFunc

You should know by now that checking for @error is always a good practice. :) 

Link to comment
Share on other sites

Good point for the Sleep(), I managed to reproduce the issue.

You can also use this one :

#Include <IE.au3>

$oIE = _IECreatePrivate("http://www.autoitscript.com")

Func _IECreatePrivate($sUrl = "about:blank", $iWait = 1)
   Local $oPrivateIE
   Local $sPFDir = (StringInStr(@OSArch, "64") AND Not @AutoItX64) ? RegRead("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir") : @ProgramFilesDir
   ShellExecute ($sPFDir & "\Internet Explorer\iexplore.exe", "-noframemerging -private about:blank", @ProgramFilesDir & "\Internet Explorer")
   Local $hPrivateIE = WinWaitActive("[REGEXPTITLE:.+\[InPrivate\]]", "", 3)
   If Not $hPrivateIE Then Return SetError(1, 0, 0)
   Sleep(200)
   $oPrivateIE = _IEAttach($hPrivateIE, "hwnd")
   If @error Then Return SetError(@error, 0, 0)
   _IENavigate($oPrivateIE, $sUrl, $iWait)
   Return $oPrivateIE
EndFunc

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...