Jump to content

Multi IE instance in private mode


Faran
 Share

Recommended Posts

Hello,

I want to login to Gmail with multi accounts i have opened 2 Ie in private mode but when i login to first Ie 2nd Ie also take first ie cookies and get login in

here are my code and i m using same function for 2nd Ie

Global $oIE = _IEInPrivateCreate("www.google.com", 2)



Func _IEInPrivateCreate($s_url, $i_timeout = -1) ; Simple version, you can add all the other stuff if you like ($i_timeout is in secs).
    Local $s_random = "about:InPrivate " & Random(1000000, 99999999, 1) & "-" & Random(1000000, 99999999, 1)
    If $s_url = "" Then $s_url = "about:InPrivate"

    Local $i_pid = Run('"' & @ProgramFilesDir & '\Internet Explorer\iexplore.exe" -private "')
    If $i_pid = 0 Then Return SetError(1, 0, 0)

    If StringInStr("|default|-1|", "|" & $i_timeout & "|") Then $i_timeout = 0

    Local $h_wnd, $o_shell, $o_shell_wins, $i_timer

    If $i_timeout > 0 Then $i_timer = TimerInit()
    While 1

        If $i_timeout And TimerDiff($i_timer) / 1000 > $i_timeout Then
            Return SetError(2, $i_pid, 0)
        EndIf

        $h_wnd = WinGetHandle($s_random)
        If $h_wnd Then ExitLoop
        Sleep(10)
    WEnd

    $o_shell = ObjCreate("Shell.Application")
    If IsObj($o_shell) Then
        $o_shell_wins = $o_shell.Windows

        For $o_shell_win In $o_shell_wins
            ; IE.au3 checks for IWebBrowser as well as IWebBrowser2 with __IEIsObjType
            ; This fails with my outlook with "hwnd" property
            ; So if its 100% neccessary, you'll need to find a work around
            If String(ObjName($o_shell_win)) = "IWebBrowser2" Then
                If $o_shell_win.hwnd = $h_wnd Then
                    Return SetError(0, $i_pid, $o_shell_win)
                EndIf
            EndIf
        Next
    EndIf

    Return SetError(3, $i_pid, 0)
 EndFunc

please tell me if there is anyother option to handle multi Ie in private mode

thanks

faran

Edited

i have tried this one put it handling only first not 2nd one

#include <IE.au3>
 Run('"' & @ProgramFilesDir & '\Internet Explorer\iexplore.exe" -private  "about:blank""')
    WinWait("Blank Page")
$oIE = _IEAttach("about:blank", "url")
_IELoadWait($oIE)
_IENavigate($oIE, "http://www.autoit.com")
$oEvt = ObjEvent($oIE, "_IEEvent_")

 Run('"' & @ProgramFilesDir & '\Internet Explorer\iexplore.exe" -private  "about:blank""')
    WinWait("Blank Page")
$oIE2 = _IEAttach("about:blank", "url")
_IELoadWait($oIE2)
_IENavigate($oIE2, "http://www.google.com")
$oEvt = ObjEvent($oIE2, "_IEEvent_")
Edited by Faran
Link to comment
Share on other sites

  • Moderators

Private mode stops them from getting information about you/your computer.  It doesn't prevent them from reading cookies.  Have you tried disabling cookies/history on each startup of IE?  Or disabling them all together as you don't want them to cross each other when IE is processing.  Other than running each in their own virtual environment, I am afraid I know no other way to prevent them from "crossing streams", so to speak.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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...