Jump to content

Private browsing generic login script


Recommended Posts

I found this piece of code that enables the IE private browser.

Source code and a link will be given below.

If you want to automate a type of login I would recommend looking at the help file. Here is the link:

https://www.autoitscript.com/autoit3/docs/libfunctions/_IEAction.htm

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <Constants.au3>
#include "IE.au3"

Local $pid, $hHandle, $hGUI, $sURL, $xHeight, $xWidth
$sURL = "www.google.com"
$xWidth = 800
$xHeight = 600

$hGUI = GUICreate("Test", $xWidth, $xHeight)
$oIE = _IECreateEmbed2(500, 500, 10, 10, $hGUI)
_IENavigate($oIE, "www.google.com")

Func _IECreateEmbed2($xWidth, $xHeight, $iX, $iY, $hGUI)
    $pID = Run(@ProgramFilesDir & "\internet explorer\iexplore.exe -private " & $sURL, "", @SW_HIDE)
    Do
        Sleep(100)
    Until Not (ProcessExists($pID) = 0)

    $hHandle = _ProcessGetHWnd($pID)

    Do
        $oIElocal = _IEAttach($hHandle, "HWND")
        Sleep(100)
    Until $oIElocal <> 0

    GUISetState(@SW_SHOW, $hGUI)
    _WinAPI_SetParent($hHandle, $hGUI)
    _WinAPI_MoveWindow($hHandle, $iX, $iY, $xWidth, $xHeight, True)
    _WinAPI_SetWindowLong($hHandle, $GWL_STYLE, BitOR($WS_CHILD, $WS_VISIBLE))

    Return $oIElocal
EndFunc;==>_IECreate2


Func _ProcessGetHWnd($iPid, $sTitle = "", $iTimeout = 2000)
     Local $aWin
     While 1
        $aWin = WinList($sTitle)
        For $i = 1 To $aWin[0][0]
        If $iPid = WinGetProcess($aWin[$i][1]) Then
            Return $aWin[$i][1]
        EndIf
        Next

    Sleep(500) ; add a timer here
    WEnd
    SetError(1)
    Return 0
EndFunc   ;==>_ProcessGetHWnd

Do
    Sleep(50)
Until GUIGetMsg() = $GUI_EVENT_CLOSE


_IEQuit($oIE)
Sleep(500) ;alternatively: use "ProcessClose" using the pid returned earlier by "Run". Or iterate on "Processexists" using the same Pid, until Processexists returns 0

 

Edited by aa2zz6
Link to comment
Share on other sites

Thanks for your help.  I have tried modifying the above script to also include automatically logging into a site such as Twitter with known account details and it doesnt appear to work.  The site opens correctly in a private window but the account credentials are not passed through.  Any ideas? 

Link to comment
Share on other sites

Thanks for your help.  I have tried modifying the above script to also include automatically logging into a site such as Twitter with known account details and it doesnt appear to work.  The site opens correctly in a private window but the account credentials are not passed through.  Any ideas? 

Hi, I have managed to get Facebook loading in a private IE window but its not pretty due to the fb message about cookies being required.  To get around this you can reload the page and it logs in properly. I have attached the script, please don't laugh to hard as its my first attempt at such a thing. 

 

What i'm really after is the ability to do something similar with Twitter, I cant get it to launch in a private browser window but it will not pass user credentials 

 

 

Any help is greatly received 

 

 

Test script for facebook private login upload.au3

Link to comment
Share on other sites

  • 2 weeks later...

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