Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

FF.au3 (V0.6.0.1b-10)


  • Please log in to reply
604 replies to this topic

#601 Rickname

Rickname

    Wayfarer

  • Active Members
  • Pip
  • 77 posts

Posted 09 July 2014 - 07:21 PM

I downloaded FF.au3 , installed MozRepl, started it, put 4242 as port in it, then when Im trying to run this simple script :

#include "FF.au3"
_FFConnect(default,Default,6000)

_FFWindowOpen("http://www.youtube.com", True, True)

The thing is, it actually works, but it is still gives me a very annoying error :

 

 

_FFConnect: OS:    WIN_7 WIN32_NT 7601 Service Pack 1
_FFConnect: AutoIt:    3.3.12.0
_FFConnect: FF.au3:    0.6.0.1b-10
_FFConnect: IP:    127.0.0.1
_FFConnect: Port:    4242
_FFConnect: Delay:     2ms
_FFConnect: Socket:     488
_FFConnect: Browser:    Mozilla/5.0 (Windows NT 6.1; rv:30.0) Gecko/20100101 Firefox/30.0
__FFSendJavaScripts: Sending functions to FireFox .......... done
_FFWindowOpen: http://www.youtube.com
_FFLoadWait: .
__FFWaitForRepl ==> Error TCPSend / TCPRecv: TCPRecv :-1

__FFWaitForRepl ==> Error TCPSend / TCPRecv: TCPRecv :-1
. loaded in 573ms
[object XrayWrapper [object HTMLDocument]] - {location: {...}, SWFUpload_0: function() {...}, rss_feed: {...}, getElementsByName: function() {...}, getItems: function() {...}, open: function() {...}, close: function() {...}, ...}
_FFWindowGetHandle: 0x00000000
_FFWindowGetHandle ==> General Error

 

What can do ? :(









#602 Iczer

Iczer

    Prodigy

  • Active Members
  • PipPipPip
  • 151 posts

Posted 10 July 2014 - 05:24 PM

See suggested changes in http://www.autoitscript.com/forum/topic/161918-ffau3-mozrepl-error/#entry1176017



#603 Gonnosuke

Gonnosuke

    Seeker

  • Normal Members
  • 9 posts

Posted 11 July 2014 - 08:17 AM

I don't know if anyone will find this useful but I recently had to automate a process that required a private browsing session and ended up writing the following function. If anyone knows how to enable private browsing via FFCmd I'd love to know. I tried and failed to get it working properly and ended up with the following method which is probably much slower than it would be if called directly.

AutoIt         
; #INTERNAL_USE_ONLY# ========================================================== ; Name ..........: _FFStartPrivate ; Description ...: Starts Private browsing session ; AutoIt Version : V3.3.10.2 ; Syntax ........: _FFStartPrivate([$sURL = "about:blank"[, $bNewWin = True[, $bPrivSession = True[, $iPort = 4242]]]]) ; Parameter(s): . ;                  $bNewWin     - Optional: (Default = True) : ;                  $bPrivSession  - Optional: (Default = True) : ;                  $iPort       - Optional: (Default = 4242) : ; Return Value: Success      - 1 ;                  Failure      - 0 ;                  @ERROR       - ;                  @EXTENDED    - hWnd from Private firefox session ; Date ..........:  6/7/2014 ; ============================================================================== Func _FFStartPrivate($sURL = "about:blank", $bNewWin = True, $bPrivSession = True, $iPort = 4242)     Local Const $sFuncName = "_FFStartPrivate"     Local $sPrivSession = ""     Local $sNewWin = ""     If $bPrivSession Then $sPrivSession = "-private-window"     If $bNewWin Then $sNewWin = "-new-window"     $sURL = '"' & $sURL & '"'     Local $sHKLM = 'HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox'     If @OSArch <> 'X86' Then $sHKLM = 'HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mozilla\Mozilla Firefox'     Local $sFFVerKey = $sHKLM & '\' & RegEnumKey($sHKLM, 1)     Local $sFFExe = RegRead($sFFVerKey & '\Main', 'PathToExe')     If @error Then         SetError(__FFError($sFuncName, $_FF_ERROR_GeneralError, "Error reading registry entry for FireFox." & @CRLF & _                 $sFFVerKey & "\Main\PathToExe" & @CRLF & _                 "Error from RegRead: " & @error))         Return 0     EndIf         Local $sCommand = StringFormat('"%s" %s %s %s "-repl %i"', $sFFExe, $sNewWin, $sPrivSession, $sURL, $iPort)     Run($sCommand)         Local $sPrivhWnd = WinWaitActive("[REGEXPTITLE:(?i)(.*Private Browsing.*)]", "", 10)     Sleep(250)     $sCmdWinSelect = 'Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow("navigator:browser")'     _FFCmd("repl.enter(" & $sCmdWinSelect & ")")        WinActivate($sPrivhWnd)     SetExtended($sPrivhWnd)         If $_FF_COM_TRACE Then         ConsoleWrite(@CRLF & '_FFStartPrivate: "' & $sCommand)         ConsoleWrite(@CRLF & '_FFStartPrivate hWnd: "' & $sPrivhWnd & @CRLF)     EndIf         If @error Then         SetError(__FFError($sFuncName, $_FF_ERROR_GeneralError, "Error launching Private session."))         Return 0     Else         Return 1     EndIf EndFunc   ;==>_FFStartPrivate

Regards,

Gonnosuke


Edited by Gonnosuke, 11 July 2014 - 08:20 AM.

  • Danp2 likes this

#604 Danp2

Danp2

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 788 posts

Posted 12 July 2014 - 02:38 PM

Here's an enhanced version of _FFWindowOpen that supports private browsing. FYI, I have not tested to see how this update may affect other functions. Let me know if you see any issues.

AutoIt         
; #FUNCTION# =================================================================== ; Name ..........: _FFWindowOpen ; Description ...: Opens a new browser window ; Beschreibung ..: Öffnet ein neues Browser Fenster. ; Syntax ........: _FFWindowOpen([$sURL = "about:blank"[, $bActivate = True[, $bLoadWait = True]]]) ; Parameter(s): .: $sURL        - Optional: (Default = "about:blank") : ;                  $bActivate   - Optional: (Default = True) ;                  $bLoadWait   - Optional: (Default = True) : ;                  $bPrivate   - Optional: (Default = False) : ; Return Value ..: Success      - 1 and sets ;                  @EXTENDED    - Window handle ;                  Failure      - 0 and sets ;                  @ERROR       - ;                  @EXTENDED    - "" ; Author(s) .....: Thorsten Willert ; Date ..........: Fri Nov 13 18:31:06 CET 2009 ; Link ..........: https://developer.mozilla.org/En/DOM/Window, https://developer.mozilla.org/En/NsIWindowMediator ; Related .......: _FFWindowSelect, _FFWindowClose, _FFWindowGetHandle ; Example .......: Yes ; ============================================================================== Func _FFWindowOpen($sURL = "about:blank", $bActivate = True, $bLoadWait = True, $bPrivate = False)     Local Const $sFuncName = "_FFWindowOpen"     If Not __FFCheckURL($sURL) Then         SetError(__FFError($sFuncName, $_FF_ERROR_InvalidDataType, "(URL) $sURL: " & $sURL))         Return 0     EndIf     Local $bTrace = $_FF_COM_TRACE     $_FF_COM_TRACE = False     ConsoleWrite("_FFWindowOpen: " & $sURL & @CRLF)     If $bPrivate Then         _FFCmd("window.PrivateBrowsingUtils.privacyContextFromWindow(window).usePrivateBrowsing = true")     Else         _FFCmd("window.PrivateBrowsingUtils.privacyContextFromWindow(window).usePrivateBrowsing = false")     EndIf     _FFCmd("window.open('" & $sURL & "');")     If $bLoadWait Then _FFLoadWait()     If Not @error Then         If _FFWindowSelect() Then             Local $hWin = @extended             If Not @error And $bActivate Then WinActivate($hWin)             __FFSendJavaScripts()             $_FF_COM_TRACE = $bTrace             SetExtended($hWin)             Return 1         EndIf     EndIf     $_FF_COM_TRACE = $bTrace     SetExtended("")     Return 0 EndFunc   ;==>_FFWindowOpen

  • 232showtime and Gonnosuke like this

#605 Gonnosuke

Gonnosuke

    Seeker

  • Normal Members
  • 9 posts

Posted 18 July 2014 - 05:16 AM

Thanks Danp2! I was using the wrong context.

 

[Edit] I found a big problem with it -- when you use _FFWindowOpen like above (or if you send keys Ctrl-Shift-P), it creates a private session that really isn't private and I think the reason is that it shares the PID with existing FF windows. For example, the reason I need to use a private session is because I don't want users to be able to save the password information in the browser (among other things). With your function, if I automate the login, do what I need to do, and then close the private session window, the login info is stored when I go back to the site in question. If I use the original function I wrote (which is based on the __FFStartProcess function) it works like it should and the login info isn't stored from session to session. I suspect it's a bug with FF and the way it's initializing the new window.


Edited by Gonnosuke, 18 July 2014 - 05:31 AM.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users