Jump to content
Sign in to follow this  
Xenobiologist

Running firefox in private mode with URL

Recommended Posts

Xenobiologist

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
Xenobiologist

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
jguinch

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
Xenobiologist

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
Xenobiologist

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
Xenobiologist

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
jguinch

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
jguinch

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
Xenobiologist

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
Xenobiologist

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  

  • Similar Content

    • rudi
      By rudi
      Hello,
      usually I do Win automations, so I have no skills at all to handle HTML forms :-/
      The script to catch and syntax check  the required information from Excel is done.
      Now I'd like to automate the upload using this form, too:
       
      http://flashcardsdeluxe.com/flashcards/Upload.aspx
      What browser is easiest to do so? (IE, Chrome, FF) The Values $DeckCode, $DeckName, $DeckDefinition shall go to their HTML form fields finally "click" the button "upload flashcards" <table width="70%" class="cssCenter" border="0"> <tr> <td style="width: 1%">Deck&nbsp;Code</td> <td style="width: 100%"><input name="ctlDeckCode" type="text" id="ctlDeckCode" style="width:50%;" /> (no spaces allowed)</td> <td></td> </tr> <tr> <td style="width: 1%">Deck&nbsp;Name</td> <td style="width: 100%"><input name="ctlDeckName" type="text" id="ctlDeckName" style="width:50%;" /> (optional)</td> <td style="width: 1%" align="right"><input type="submit" name="ctlUpload" value="Upload Flashcards" id="ctlUpload" /></td> </tr> <tr> <td valign="top" style="padding-top: 5px" >Flashcard&nbsp;Text</td> <td colspan="2"><textarea name="ctlFlashcardText" rows="2" cols="20" id="ctlFlashcardText" style="height:280px;width:100%;"></textarea></td> </tr> </table> If someone kindly could jump in showing how to address just one of the input fields and how to "click" the "upload flashcards" button, I should be able to do the rest myself.
      TIA, Rudi.

    • Faraz
      By Faraz
      I have to open a URL on Mozilla Firefox , cursor is by default userid textbox, had to send userid, send tab, send pwd with flag 1 , send tab, send Enter.
      But Script is Failing to take Password.
      Any Help
       
      #include <Constants.au3>
      #include <IE.au3>
      #include <PassMask.au3>
      If $CmdLine[0] <> 3 Then
          MsgBox($MB_OK, "Usage", "ps_weblogin_FireFox <Url> <Browser Title> <Text to Send>")
      Else
         web_login($CmdLine[1], $CmdLine[2], $CmdLine[3])
      EndIf
      Func web_login($bt_url, $bt_Title, $bt_SendText)
          Local $ff = Run("C:\Program Files (x86)\Mozilla Firefox\firefox.exe " & $bt_url)
              WinWaitActive($bt_Title)
          Sleep(2000)
          ControlSend("","","",$bt_SendText)
      EndFunc
      _______________________________________________
      _______________________________________________
      Func Mask_Password($Password)
          $MaskPassword = $Password
          $MaskPassword = StringReplace($MaskPassword, "#", "||||||#@@@@@@")
          $MaskPassword = StringReplace($MaskPassword, "!", "||||||!@@@@@@")
          $MaskPassword = StringReplace($MaskPassword, "+", "||||||+@@@@@@")
          $MaskPassword = StringReplace($MaskPassword, "^", "||||||^@@@@@@")
          $MaskPassword = StringReplace($MaskPassword, "{", "||||||{@@@@@@")
          $MaskPassword = StringReplace($MaskPassword, "}", "||||||}@@@@@@")
          $MaskPassword = StringReplace($MaskPassword, "||||||", "{")
          $MaskPassword = StringReplace($MaskPassword, "@@@@@@", "}")
          Return $MaskPassword
      EndFunc
    • Marc
      By Marc
      Profiler - yet another backup script for Firefox and Thunderbird profiles
      It automatically detects the last recently used profile directories of Firefox and Thunderbird (installed versions, no portables).
      Clicking the Backup-Button creates a complete Backup of the found profiles with a timestamp.
      Restore deletes the according profile dir and extracts the content of the selected archive into the profile directory.
      Uses Winrar as compression tool, but feel free to change it to your needs
      Best regards
      Marc

      Profiler.au3
    • BOUNCER
      By BOUNCER
      I'm trying to get the output data from https://www.guilded.gg but it uses a web app that generates that output on the fly and this doesn't show up in the page source.
      Only in web inspector of each browser does this data show up. How do I read this data in autoit (equivalent to the web inspector)
       
      thank you
    • Pao
      By Pao
      Hello, I've recently updated from Firefox 50 to 54.0.1.
      My Autoit script that previously worked fine, now seems to have erratic problems.
      It's almost as if some Send() commands are sometimes skipped when dealing with the Firefox UI (it's still mostly fine on the actual pages).

      To temporarly fix the problem, I had to put some Sleep(200) pauses and avoid grouping keys together (e.g: TAB 2), but I'm not exactly sure about the correct way to deal with this..
      Could this be caused by the new multiprocess feature? (e10s)
      Are there better Autoit commands or rules that I should use?
       
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.