Sign in to follow this  
Followers 0
Xenobiologist

Running firefox in private mode with URL

15 posts in this topic

Hello guys,

I 've written a little application in Autoit which starts IE or firefox with a html file which is generated before. The file contains the URL which shall be started.

What I'm trying to do is start firefox in private mode and directly load the file.

This doesn't work. All I have done successfully is start firefox in private mode and then "ControlSend" the complete filename (path) and hit enter.

Then firefox transforms the path into the file:/// ... syntax and loads the url.

This works, but using ControlSend isn't the best way, because it sometimes fails when a sign gets lost during send-process.

Does anybody know an option to just use an Autoit command to run a private window with the given filename (path)?

The exact call looks this way at the moment:

                ShellExecute(@ProgramFilesDir & '\Mozilla Firefox\firefox.exe ', '-private-window ', @ProgramFilesDir)
;~                 ShellExecute(@ProgramFilesDir & '\Mozilla Firefox\firefox.exe ', ' -private-window' & ' -url file:///' & StringReplace($filename, '\', '/'), @ProgramFilesDir)
                ConsoleWrite('private Mode FF' & @CRLF)
                Local $ff_handle = WinWaitActive('Privater Modus - Mozilla Firefox (Privater Modus)', '', 5)
                Sleep(100)
;~                 Opt('SendAttachMode', 1)
                Opt('SendKeyDelay', 5)
                Opt('SendKeyDownDelay', 1)
                ControlFocus($ff_handle, '', '')
                ControlSend($ff_handle, '', '', $filename & '{ENTER}')

The file looks like this:

<html>
    <head>
        <title> Reporting-Manager ANMELDUNG </title>
    <script>
        function createCookie(name, value, days) {
            if (days) {
            var date = new Date();
            date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
            var expires = "; expires=" + date.toGMTString();
        }
            else var expires = "";
            document.cookie = name + "=" + value + expires + ";domain=.dsp-mgY.gaxeg.de;path=/cognos01";
    }

        function eraseCookie(name) {
        createCookie(name, "", -1);
}

            function logMeIn(){ 
                window.opener=null;
                eraseCookie("cc_session");
                eraseCookie("caf");
                eraseCookie("cam_passport");
                eraseCookie("userCapabilities");
                eraseCookie("CRN");
                eraseCookie("CGC");
                eraseCookie("usersessionid");
                eraseCookie("cea-ssa");

                document.getElementById("formLogin").submit();
            };

            onload = function() {
                        logMeIn();
                     }

    </script>
</head>
<body>
<form style="margin:0px;padding:0px;" method="post" action="http://dsp-mgY.gaxeg.de/cognos01/cgi-bin/cognos_module" name="pform" id="formLogin">
    <input type="hidden" name="b_action" value="xts.run" id="inputBaction">
    <input type="hidden" name="startwel" value="yes" id="inputStartwel">
    <input type="hidden" name="m" value="portal/main.xts" id="inputM">
    <input type="hidden" name="h_CAM_action" value="logonAs">
    <input type="hidden" name="CAMNamespace" value="ldap" id="inputCamNamespace">
    <input type="hidden" name="CAMUsername" value="xxx" id="CAMUsername">
    <input type="hidden" name="CAMPassword" value="xxx" id="CAMPassword">
    <input type="hidden" name="bank21.funktionsmandant" value="0112" id="bank21.funktionsmandant">

    <div style="width: 150px; height: 50px; margin-left: auto; margin-right: auto; margin-top: 300px; text-align: center">
        <img src="http://dsp-mgY.gaxeg.de/cognos01//ps/portal/images/icon_loading.gif" width="32" height="32"/><br/><br/>
        Bitte warten<br/><br/>
        Anmeldung an Reporting ...
    </div>
</form>
</body>
</html>

Thanks for any help.

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites



You mean this?

ShellExecute(@ProgramFilesDir & '\Mozilla Firefox\firefox.exe ', $filename & ' -private-window ', @ProgramFilesDir)

This leads to a normal firefox window in which the automatic login from the file happens and to a second firefox window. The second is private but doesn't start any URL or something else. 

 


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Sorry, I meant that the "-url" parameter is not necessary, because the url itself is a parameter :

ShellExecute(@ProgramFilesDir & '\Mozilla Firefox\firefox.exe ', ' -private-window' & ' file:///' & StringReplace($filename, '\', '/'), @ProgramFilesDir)

Share this post


Link to post
Share on other sites

I tried that before. Same behauviour. Firefox opens two windows.

1 - with the login is NON-Private

2 - private-mode window without any further action (like start new tab in private mode)


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

I created a new script with just this one line

ShellExecute("C:\Program Files (x86)\Mozilla Firefox\firefox.exe", ' -private-window' & ' file:///' & StringReplace("C:\Users\xf01145\AppData\Local\Temp\bank21-Reporting-Manager.html", '\', '/'), @ProgramFilesDir)

File is opened in normal mode and there is an additional window opened in private mode . :mad2:


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

I have to use 24 the last long time support version.


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

OK, I will try it tomorrow at work (with 24 ESR too).

If you cannot do it with the -private-window launching option, another way could be to use a temporary FF profile to do the same thing than a private browsing.

ShellExecuteWait(@ProgramFilesDir & '\Mozilla Firefox\firefox.exe ', '-profile "' & @TempDir & "\temporaryProfile" & '" http://www.google.com', @ProgramFilesDir)
DirRemove(@TempDir & "\temporaryProfile", 1)

But sure, it's less clean...

Share this post


Link to post
Share on other sites

Well, I reproduce the same issue at work with the version 24 (ESR). It's a know issue, which seems to be corrected with some last versions...

Here is a link for a conversation about the same thing : http://forums.mozillazine.org/viewtopic.php?f=38&t=2734967.

If you have to use a long time supported version, the next release (31 ESR) is on rails, scheduled for July (https://www.mozilla.org/en-US/firefox/organizations/faq/)

You can also try with my previous code, which use a temporary profile (equivalent to a private browsing).

Share this post


Link to post
Share on other sites

Ah thanks, so it is a bug in firefox. I tried the example with the temp profile. Same result as before.

So, I will keep the ControlSend solution until we update to version 31.

Thanks!


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Problem solved with firefox 31 the bug is gone.


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Similar Content

    • rte7
      By rte7
      Hello. We work with the BMC Remedy site to manage incidents and would like to automate the processes of clicking through this button code:
      <a href="javascript:" class="btn btn3d menu" style="top:21; left:184; width:21; height:21;"> <img class="btnimg" src="../../../../resources/images/mt_sprites.gif" alt="menu category issue" title=""> </a> I use firefox with mozrepl and autoit with include FF.au3
      I need your help
      I read the topic https://www.autoitscript.com/forum/topic/95595-ffau3-v0601b-10/ but I could not run the code from the listed commands
      ...
      It is necessary to press the button and from the list of the menu of cahorsations to select the item = "zone of trust abonent"
      Screen # 1 http://joxi.ru/52aJK7bh4a7ypA or below.
      1) Press button
      <a href="javascript:" class="btn btn3d menu" style="top:21; left:184; width:21; height:21;"> <img class="btnimg" src="../../../../resources/images/mt_sprites.gif" alt="menu category issue" title=""> </a>
      2) After pressing the button, I need to choose in this menu of 4 items to select an item called "zone of trust abonent", Screen # 2 - http://joxi.ru/p27gwQKHo71VQ2
      html code table items
      <table class="MenuTable" cellpadding="0" cellspacing="0" style="width: 179px;"> <tbody class="MenuTableBody"> <tr class="MenuTableRow"> <td class="MenuEntryName" nowrap="">zone of trust abonent</td> <td class="MenuEntryNoSub" arvalue="zone of trust abonent"></td> </tr> <tr class="MenuTableRow"><td class="MenuEntryName" nowrap="">zone of trust operator</td> <td class="MenuEntryNoSub" arvalue="zone of trust operator"></td> </tr> <tr class="MenuTableRow"><td class="MenuEntryName" nowrap="">zone of trust third operator</td> <td class="MenuEntryNoSub" arvalue="zone of trust third operator"></td></tr> <tr class="MenuTableRow"><td class="MenuEntryNameHover" nowrap="">No settings</td> <td class="MenuEntryNoSubHover" arvalue="No settings"></td> </tr> </tbody> </table>
       
       
      More in detail, I choose from the menu item "zone of trust abonent" Screen # 3 - http://joxi.ru/GrqVq4ZIQEPW4m

       
      3) The choice is made, Screen # 4 http://joxi.ru/v297w6aC3PovLr
      <textarea class="text sr " wrap="off" id="arid_WIN_0_1000002488" cols="20" maxlen="60" style="top:21; left:0; width:179; height:21;" armenu="CFG:PRC:CategoryHPD-Res-T1-Q" mstyle="2" arautoc="1" arautocmb="1" arautocak="0" arautoctt="400" rows="1"> </textarea>
       
      It's all. I would be very grateful to you =) !!!!!!!!!!
      Here are more detailed codes in the attachment. 
      button1.txt
      menu - table.txt
      all.txt
    • milos83
      By milos83
      How can I check if element is focused in Firefox using FF.au3 UDF?
      This is my try:
      I have prepared a function that checks if the object is focused:
       
      _FFCmd('FFau3.isfocused=function isfocused(a){try{return (a === document.activeElement)}catch(e){return}}') $oElm = _FFXPath("//*[@id='someId']") ConsoleWrite(_FFIsFocused($oElm)) Func _FFIsFocused($sElement = "") Local $isFoc = _FFCmd("FFau3.isfocused(" & $sElement & ")") Return $isFoc EndFunc ;==>_FFIsFocused Now, the javascript part is tested and it does return successfully.
      After a lot of try/fails I inserted an alert box in order to display the object being compared.
      Here is what I got
       
      The focused object is: [object XULElement]
      The object that I send for comparing is [object HTMLInputElement]
      Why is that?
       
       
    • spuuunit
      By spuuunit
      Is it possible to know if a textbox is active in FireFox?
       
      This is what I want:
      if (Textbox in FireFox == Active) { }
    • tonycst
      By tonycst
      I want to pass "about:config" to firefox
      If i do ShellExecute ("firefox.exe","about:config"), i get new instance of firefox opening up which is bad because it makes changes to another profile instead of one that is currently running.
      Any ideas ?
    • mazz3d
      By mazz3d
      hello  everyone,
      I'm new with AutoIT and just looking for a way to open Firefox with random window size
      i have tried too many different samples from the web, some how it works but i can't make it works with Firefox 
      MozRpel and ff.au3 installed 
      right now i can open Firefox with this code, but i still can't control the window of Firefox
      ; open firefox #include <ff.au3> _FFStart() ; open firefox with random size