Jump to content

Recommended Posts

Posted

@mootius:

The function _FF_Call is for executing JavaScripts:

FFEx.au3

@13lack13lade:

You can interact with them e.g. with _FFXpath and _FFClick.

Look please on the examples: _FFClick and _FFXpath

The XPath can you copy from FireBug.

 

Hey, got firebug, not sure how to interact with the buttons since they all have the same class name, no id, no tags, nothing this is what it says when i view source code of the object im trying to click on

<div class="html-face">Location</div>

using firebug to copy xpath i get :

/html/body/div/div/div[2]/div/div[4]/div/div[2]/div/div[2]/div/div/div/div[3]/div/div[2]/div/div[3]/div/div[2]/div/div[5]/table/tbody/tr/td/table/tbody/tr/td[3]/div/div/div/div/div

how do i use any of this to click on the button? :(

Posted

Hey, got firebug, not sure how to interact with the buttons since they all have the same class name, no id, no tags, nothing this is what it says when i view source code of the object im trying to click on

<div class="html-face">Location</div>

using firebug to copy xpath i get :

/html/body/div/div/div[2]/div/div[4]/div/div[2]/div/div[2]/div/div/div/div[3]/div/div[2]/div/div[3]/div/div[2]/div/div[5]/table/tbody/tr/td/table/tbody/tr/td[3]/div/div/div/div/div

how do i use any of this to click on the button? :(

_FFClick(_FFXPath("/html/body/div/div/div[2]/div/div[4]/div/div[2]/div/div[2]/div/div/div/div[3]/div/div[2]/div/div[3]/div/div[2]/div/div[5]/table/tbody/tr/td/table/tbody/tr/td[3]/div/div/div/div/div") )

That's all

Posted (edited)

oh, haha here i am trying to over complicate it..  i gave it a crack and the website errored something about cache then permission denied then logged me out... 

 lineNumber: 11841
 columnNumber: 28812: Permission denied to access property 'type'.
 
 
Autoit returns the following:
 
_FFConnect: Browser: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0
__FFSendJavaScripts: Sending functions to FireFox .......... done
__FFSend: FFau3.xpath=null;try{FFau3.xpath=FFau3.WCD.evaluate("/html/body/div/div/div[2]/div/div[4]/div/div[2]/div/div[2]/div/div/div/div[2]/div/ul/li[2]/a",FFau3.WCD,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;}catch(e){'_FFXPath_Error: '+e;};
__FFRecv: - {toString: function() {...}, target: "", download: "", ping: "", rel: "", hreflang: "", type: "", ...}
__FFSend: try{FFau3.simulateEvent(FFau3.xpath,'MouseEvents','click');}catch(e){'_FFCmd_Err';};
 
__FFWaitForRepl ==> Error TCPSend / TCPRecv: TCPRecv :-1
__FFRecv: 
_FFClick ==> No match: $sElement: FFau3.xpath
>Exit code: 0    Time: 4.903
Edited by 13lack13lade
  • 2 weeks later...
Posted (edited)

For give me I'm new to the ff.au3 library but how would i go about getting a list of id's class's or name's from a specific element then retrieve the inner text from each element returned.

like this

<div id="conainer">

<div id="box1">
some text
</div>

<div id="box2">
some text
</div>

<div id="box3">
some text
</div>

</div>
Edited by gishi
Posted

I have added the UDF and the firefox addon and the AddOn MozRepl

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\joesoef pc\Desktop\autoit\firefox.au3" /UserParams    
+>09:14:18 Starting AutoIt3Wrapper v.2.1.4.4 SciTE v.3.3.7.0 ;  Keyboard:00020409  OS:WIN_81/  CPU:X64 OS:X64    Environment(Language:0413  Keyboard:00020409  OS:WIN_81/  CPU:X64 OS:X64)
>Running AU3Check (3.3.10.2)  from:C:\Program Files (x86)\AutoIt3
+>09:14:18 AU3Check ended.rc:0
>Running:(3.3.10.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\joesoef pc\Desktop\autoit\firefox.au3"    
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
__FFStartProcess ==> General Error: Error reading registry entry for FireFox.
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mozilla\Mozilla Firefox\*CurrentVersion*\Main\PathToExe
Error from RegRead: 1
_FFConnect: OS: WIN_81 WIN32_NT 9600 
_FFConnect: AutoIt: 3.3.10.2
_FFConnect: FF.au3: 0.6.0.1b-10
_FFConnect: IP: 127.0.0.1
_FFConnect: Port:   4242
_FFConnect: Delay:  2ms
_FFConnect: Socket:     732
_FFConnect: Browser:    Mozilla/5.0 (Windows NT 6.3; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0

__FFWaitForRepl ==> Error TCPSend / TCPRecv: TCPRecv :-1
__FFSendJavaScripts: Sending functions to FireFox .......... done
_FFLoadWait: . loaded in 11ms

__FFWaitForRepl ==> MozRepl Exception

+>09:14:20 AutoIt3.exe ended.rc:0
+>09:14:20 AutoIt3Wrapper Finished..
>Exit code: 0    Time: 3.010
 

And this is the simple script i try to run:

#include <FF.au3>

_FFStart("http://www.youtube.com/")

im using firefox version:27.0.1

can somebody please help me

Posted

Here is a half a$$ script I wrote to check ff and mozrepl status (it is only reliable if firefox.exe is installed in default location).

I just use "get status" button. Hope it is helpful to you.

#Region    ;************ Includes ************
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <GuiEdit.au3>
#include <File.au3>
#include <WinAPIEx.au3>
#include <APIConstants.au3>
#EndRegion    ;************ Includes ************


If _Singleton("Mozrepl Manager.exe", 1) = 0 Then
    MsgBox(0, "Mozrepl Manager is already running! ", " Using multiple copies of this script is unsupported! ")
    Exit
EndIf
Opt("MustDeclareVars", 1)
Opt("TrayIconDebug", 1)
HotKeySet("{END}", "__MyExit")
Global $MSG
Global $FireFoxInst = False, $FMOZREPLINST = False, $FMOZREPAUTOSTART = False
Global $HMAINGUI = GUICreate("Mozrepl Manager", 540, 150, -1, -1)
Global $ECONSOLE = GUICtrlCreateEdit("", 1, 30, 540, 120, -1)
GUICtrlSetFont(-1, 10)
Global $BREPLSTATUS = GUICtrlCreateButton("Get Status", 4, 4, 60, 20)
Global $BINSTALLMOZREPL = GUICtrlCreateButton("Install Mozrepl", 68, 4, 74, 20)
Global $BFIREFOXSTATUS = GUICtrlCreateButton("Firefox Exists", 146, 4, 70, 20)
GUISetState()
$FireFoxInst = __FIREFOXEXISTS()
While 1
    $MSG = GUIGetMsg(1)
    Select
        Case $MSG[0] = $GUI_EVENT_CLOSE And $MSG[1] = $HMAINGUI
            __MYEXIT()
        Case $MSG[0] = $BREPLSTATUS And $MSG[1] = $HMAINGUI
            __REPLSTATUS()
        Case $MSG[0] = $BINSTALLMOZREPL And $MSG[1] = $HMAINGUI
            __INSTALLMOZREPL()
        Case $MSG[0] = $BFIREFOXSTATUS And $MSG[1] = $HMAINGUI
            __FIREFOXEXISTS()
    EndSelect
WEnd
Func __INSTALLMOZREPL()
    ShellExecute("https://addons.mozilla.org/firefox/downloads/file/205776/mozrepl-1.1.2-fx.xpi?src=dp-btn-primary", "", "", "open")
EndFunc   ;==>__INSTALLMOZREPL
Func __REPLSTATUS()
    Local $AFILELIST, $LISTERROR, $RETURN, $VAR, $BOOL
    If Not $FireFoxInst = True Then
        _GUICtrlEdit_AppendText($ECONSOLE, " Firefox is not installed at the directory: " & @AppDataDir & "\Mozilla" & @CRLF)
        _GUICtrlEdit_AppendText($ECONSOLE, " First install Firefox" & @CRLF & " This program only supports Firefox installed on your boot drive" & @CRLF)
        Return
    EndIf
    Local $DEFAULTNAME, $ARR = _FileListToArray(@AppDataDir & "\Mozilla\Firefox\Profiles", "*", 2)
    If IsArray($ARR) Then
        For $I = 1 To $ARR[0]
            $VAR = StringInStr($ARR[$I], ".default")
            If $VAR > 0 Then
                $DEFAULTNAME = $ARR[$I]
                _GUICtrlEdit_AppendText($ECONSOLE, "Found default profile folder" & @CRLF & "Default Profile: " & $DEFAULTNAME & @CRLF)
                ExitLoop
            EndIf
        Next
    EndIf
    _GUICtrlEdit_AppendText($ECONSOLE, "Searching  " & @AppDataDir & "\Mozilla\Firefox\Profiles\" & $DEFAULTNAME & " for prefs.js" & @CRLF)
    $ARR = _FileListToArray(@AppDataDir & "\Mozilla\Firefox\Profiles\" & $DEFAULTNAME, "prefs.js")
    Local $PREFFILE
    If IsArray($ARR) Then
        For $I = 1 To $ARR[0]
            If $ARR[$I] = "prefs.js" Then
                _GUICtrlEdit_AppendText($ECONSOLE, "Found prefs.js" & @CRLF)
                $PREFFILE = $ARR[$I]
                ExitLoop
            EndIf
        Next
        If Not $PREFFILE = "prefs.js" Then
            _GUICtrlEdit_AppendText($ECONSOLE, "prefs.js not found. You will have to install The Mozrepl Addon with Firefox." & @CRLF)
            Return
        EndIf
    EndIf
    $VAR = _FileReadToArray(@AppDataDir & "\Mozilla\Firefox\Profiles\" & $DEFAULTNAME & "\" & $PREFFILE, $ARR)
    If $VAR = 0 Then
        If @error = 1 Then _GUICtrlEdit_AppendText($ECONSOLE, " Error opening prefs.js" & @CRLF)
        If @error = 2 Then _GUICtrlEdit_AppendText($ECONSOLE, " Error reading prefs.js" & @CRLF)
        Return
    EndIf
    If IsArray($ARR) Then
        Local $STRING
        _GUICtrlEdit_AppendText($ECONSOLE, "Checking if Mozrepl is installed" & @CRLF)
        $VAR = ""
        For $I = 1 To $ARR[0]
            $VAR = StringInStr($ARR[$I], "mozrepl")
            If $VAR > 0 Then
                $FMOZREPLINST = True
                _GUICtrlEdit_AppendText($ECONSOLE, "Mozrepl is installed already" & @CRLF)
                For $J = 1 To $ARR[0]
                    $STRING = StringInStr($ARR[$J], 'user_pref("extensions.mozrepl.autoStart", true);')
                    If $STRING > 0 Then
                        $FMOZREPAUTOSTART = True
                        _GUICtrlEdit_AppendText($ECONSOLE, "Mozrepl is already set to auto start" & @CRLF)
                        Return
                    EndIf
                Next
                If $STRING = 0 Then
                    $FMOZREPAUTOSTART = False
                    _GUICtrlEdit_AppendText($ECONSOLE, "Mozrepl is not set to auto start" & @CRLF)
                    Local $FILE = FileOpen(@AppDataDir & "\Mozilla\Firefox\Profiles\" & $DEFAULTNAME & "\" & $PREFFILE, 1)
                    If Not $FILE > -1 Then
                        $BOOL = FileWrite($FILE, 'user_pref("extensions.mozrepl.autoStart", true);')
                        If $BOOL = 1 Then
                            $FMOZREPAUTOSTART = True
                            _GUICtrlEdit_AppendText($ECONSOLE, "Mozrepl is now set to auto start" & @CRLF)
                            Return
                        EndIf
                    Else
                        _GUICtrlEdit_AppendText($ECONSOLE, "Error occurred trying to open prefs.js" & @CRLF)
                        _GUICtrlEdit_AppendText($ECONSOLE, "Alternately, you could open Firefox/Tools/Mozrepl then select activate on start up." & @CRLF)
                        Return
                    EndIf
                EndIf
                ExitLoop
            EndIf
        Next
        If $VAR = 0 Then
            $FMOZREPLINST = False
            _GUICtrlEdit_AppendText($ECONSOLE, "Mozrepl not found" & @CRLF)
        EndIf
    EndIf
EndFunc   ;==>__REPLSTATUS
Func __FIREFOXEXISTS()
    Local $VAR = DirGetSize(@AppDataDir & "\Mozilla\Firefox", 3)
    If $VAR = -1 And @error = 1 Then
        _GUICtrlEdit_AppendText($ECONSOLE, " Firefox is not installed at the directory: " & @AppDataDir & "\Mozilla" & @CRLF)
        _GUICtrlEdit_AppendText($ECONSOLE, " First install Firefox" & @CRLF & " This program only supports Firefox installed on your boot drive" & @CRLF)
        $FireFoxInst = False
        Return $FireFoxInst
    EndIf
    If $VAR >= 0 Then
        _GUICtrlEdit_AppendText($ECONSOLE, "Firefox is installed at the directory: " & @AppDataDir & "\Mozilla\Firefox" & @CRLF)
        $FireFoxInst = True
        Return $FireFoxInst
    EndIf
EndFunc   ;==>__FIREFOXEXISTS
Func __MYEXIT()
    GUIDelete($HMAINGUI)
    Exit
EndFunc   ;==>__MYEXIT
Posted

Same problem as

Arclite86

 

I did EVERYTHING PERFECT :

Started MozRep, set it as auto start, put FF.au3 and FFEx.au3 in the Includes directory and included thme in my project, and then tested a little example script from the example menu of this UDF and same ERRORS as Arclite86 :(((
 

Posted (edited)

Ok I managed the above, I don't know how but somehow, BUT I have ANOTHER BIG problem ! :

I included the FF UDF but it still gives me "undefined function" error !
 

The funny part is, that actually it includes the file because if I put a Msgbox() function in the UDF , it runs the function so it reads the UDF but it does'nt recognises the declared functions from it globally

Can you explain this ??

Edited by Rickname
Posted

Post your script that isn't working, otherwise we'd be guessing what you did wrong.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted

Test #1

#cs ================================================================
    Title: NewScript.au3                2/16/2014 2:03:58 PM
    Author: SupaNewb
    AutoIt Version: 3.3.10.2
    SciTE Version 3.3.7
    Mozrepl Version 1.1.2
    Firefox Version 27.0.1
#ce ================================================================

#include <FF.au3>

_FFStart("http://www.youtube.com/")

;Console output:

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\SupaNewb\Desktop\NewScript2.au3" /UserParams
+>14:14:06 Starting AutoIt3Wrapper v.2.1.4.4 SciTE v.3.3.7.0 ;  Keyboard:00000409  OS:WIN_7/Service Pack 1  CPU:X64 OS:X86    Environment(Language:0409  Keyboard:00000409  OS:WIN_7/Service Pack 1  CPU:X64 OS:X86)
>Running AU3Check (3.3.10.2)  from:C:\Program Files\AutoIt3
! Au3check doesn't support input files encoded as UTF8 with BOM: C:\MyAutoit\MyIncludes\FF.au3
"C:\Users\SupaNewb\Desktop\NewScript2.au3"(12,35) : error: _FFStart(): undefined function.
_FFStart("http://www.youtube.com/")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\SupaNewb\Desktop\NewScript2.au3 - 2 error(s), 0 warning(s)
!>14:14:06 AU3Check ended. Press F4 to jump to next error.rc:2
+>14:14:06 AutoIt3Wrapper Finished..
>Exit code: 2    Time: 0.595

Test #2

#cs ================================================================
    Title: NewScript.au3                2/16/2014 2:04:52 PM
    Author: SupaNewb
    AutoIt Version: 3.3.10.2
    SciTE Version 3.3.7
    Mozrepl Version 1.1.2
    Firefox Version 27.0.1
#ce ================================================================
#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Run_Au3Check=n
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****

;http://www.autoitscript.com/forum/topic/157309-include-errors-after-upgrading-to-33100/

#include <FF.au3>

_FFStart("http://www.youtube.com/")

;Console output:

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\SupaNewb\Desktop\NewScript3.au3" /UserParams
+>14:18:07 Starting AutoIt3Wrapper v.2.1.4.4 SciTE v.3.3.7.0 ;  Keyboard:00000409  OS:WIN_7/Service Pack 1  CPU:X64 OS:X86    Environment(Language:0409  Keyboard:00000409  OS:WIN_7/Service Pack 1  CPU:X64 OS:X86)
>Running:(3.3.10.2):C:\Program Files\AutoIt3\autoit3.exe "C:\Users\SupaNewb\Desktop\NewScript3.au3"
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
__FFStartProcess: ""C:\Program Files\Mozilla Firefox\firefox.exe" -new-window "http://www.youtube.com/"  "-repl 4242 "
_FFConnect: OS: WIN_7 WIN32_NT 7601 Service Pack 1
_FFConnect: AutoIt: 3.3.10.2
_FFConnect: FF.au3: 0.6.0.1b-10
_FFConnect: IP: 127.0.0.1
_FFConnect: Port:   4242
_FFConnect: Delay:  2ms
_FFConnect: Socket:     616
_FFConnect: Browser:    Mozilla/5.0 (Windows NT 6.1; rv:27.0) Gecko/20100101 Firefox/27.0
__FFSendJavaScripts: Sending functions to FireFox .......... done
_FFLoadWait: . loaded in 11ms
[object XrayWrapper [object HTMLDocument]] - {flashFilesList: {...}, videoFilesList: {...}, location: {...}, logo: {...}, logoutForm: {...}, movie_player: function() {...}, masthead_child: function() {...}, ...}
+>14:18:12 AutoIt3.exe ended.rc:0
+>14:18:12 AutoIt3Wrapper Finished..
>Exit code: 0    Time: 5.020

I am guessing this is the 'undefined Function error'. I had no issues until upgrading Autoit version 3.3.8.1 to version 3.3.10.2.

Strange though, if I paste the entire UDF (FF.au3) in any of my scripts then it works like a charm(without turning off Au3check).

Posted

I've now installed the 3.3.8.1 version because i cant get the 3.3.10.2.version set to work, i am still getting a an error but its not that big any more there seems to be a problem with the mozilla firefox location:

This is where the mozilla firefox is located:

20i8745.jpg

 

And this is the error i get:

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\joesoef pc\Desktop\autoit\firefox.au3" /UserParams    
+>13:41:36 Starting AutoIt3Wrapper v.2.1.4.4 SciTE v.3.3.7.0 ;  Keyboard:00020409  OS:WIN_81/  CPU:X64 OS:X64    Environment(Language:0413  Keyboard:00020409  OS:WIN_81/  CPU:X64 OS:X64)
>Running AU3Check (1.54.22.0)  from:C:\Program Files (x86)\AutoIt3
+>13:41:36 AU3Check ended.rc:0
>Running:(3.3.8.1):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\joesoef pc\Desktop\autoit\firefox.au3"    
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
__FFStartProcess ==> General Error: Error reading registry entry for FireFox.
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mozilla\Mozilla Firefox\*CurrentVersion*\Main\PathToExe
Error from RegRead: 1
+>13:41:36 AutoIt3.exe ended.rc:0
+>13:41:36 AutoIt3Wrapper Finished..
>Exit code: 0    Time: 0.636

I dont know exactly how to solve this, should I create a new map in the "HKEY_LOCAL_MAHCINESOFTWAREWow6432NodeMozilla Firefox" named *CurrentVersion* like its been shown in the error and than create  a Main map?  How can i solve this so autoit can locate firefox?

Posted

 

Somewhere along the way, a backslash has been accidentally removed from the ff.au3 code. To solve the issue, change this line:

Local $sFFExe = RegRead($sHKLM & "" & RegRead($sHKLM, "CurrentVersion") & "\Main", "PathToExe")

to:

Local $sFFExe = RegRead($sHKLM & "\" & RegRead($sHKLM, "CurrentVersion") & "\Main", "PathToExe")

thank you so much, it worked.. finally

  • 4 weeks later...
  • 5 weeks later...
Posted (edited)

Hello everyone,

Can somone give me a code example to show me how to simulate a  mouse right click on a html element (image,..etc)?

Also, need an code example which get html element postion related to screen.

Thanks

Edited by pleasehelp
  • 4 weeks later...
Posted (edited)

Please correct me if I am wrong, but this part of the code of _FFTableWriteToArray just doesn't make sense, since tables are not constructed this way. To solve this the second half should be deleted, because it doesn't swith the row and makes each row consist of the same information from the first row.

$aRows = _FFXPath($sTable & "//tr//td[" & $i + 1 & "]", $sReturnMode, 6, $iFilter)
Else
        $iCols = _FFXPath($sTable & "//tr[last()]//td", Default, 10)
        Local $aTable[$iRows][$iCols]

        If $iCols > $iRows Then
            For $i = 0 To $iRows - 1
                $aCols = _FFXPath($sTable & "//tr[" & $i + 1 & "]//td", $sReturnMode, 6, $iFilter)
                If $aCols[0] > 0 Then
                    For $j = 0 To $iCols - 1
                        $aTable[$i][$j] = $aCols[$j + 1]
                    Next
                EndIf
            Next
        Else
            For $i = 0 To $iCols - 1
                $aRows = _FFXPath($sTable & "//tr//td[" & $i + 1 & "]", $sReturnMode, 6, $iFilter)
                If $aRows[0] > 0 Then
                    For $j = 0 To $iRows - 1
                        $aTable[$j][$i] = $aRows[$i + 1]
                    Next
                EndIf
            Next
        EndIf
    EndIf
Edited by wizardme
  • 1 month later...
Posted (edited)

Excellent, thank you for this script.

Translated some comments and variable names to English:

 

I apologize if responding to a 5 year old post with an update is considered poor form but I frequently refer to this thread when looking for further information on FF.au3 and suspect I'm not the only one and decided to post the code below for posterity. I've made a few small updates to the MozRepl_Detect() function originally created by Stilgar (Thorsten Willert) and updated by Manadar. I needed to deploy a script that uses mozrepl to several workstations and found the original script useful, but badly in need of an update to accomodate 64-bit OS's and the latest versions of Firefox. I wasn't very thorough and didn't add much in the way of error-checking, but it got the job done. Please feel free to edit/correct as you see fit .

;===============================================================================
#cs
    AutoIt Version: v3.3.12.0
    Author: Thunder-man (Frank Michalski)

    Script Function:  _MozRepl_Detect()
    Description:      Checks a Firefox profile for the MozRepl extension and installes it if not available.
    default:          $sProfile = "default"
    Return values:    True or False
    V 1.0 ==> 15.09.2007
    V 1.1 ==> 02.08.2008, updated by Stilgar (Thorsten Willert)
    changed the path-macro to @AppDataDir
    changed the ""-profil to "default"
    V1.2 ==> 03.03.2009, updated by Stilgar (Thorsten Willert)
    changed MozLab to MozRepl
    V2.0 ==> 17.03.2009, added intall-option for MozRepl by Stilgar (Thorsten Willert)
    V3.0 ==> 6/11/2014 by Gonnosuke.  Changes are below:
        *  Updated the download path for mozrepl
        *  Added support for Wow6432Node reg entry when 32bit FF is installed on 64-bit OS  
         (Note: Win7/8.x have an AppPaths reg key that make the process of reading path info easier. 
          I haven't used it here for the sake of consistency but if interested the key is below: 
          HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths 
        *  Updated the routine that reads FF path and version information from the registry. 
        *  The profiles.ini file has a (new?) key called IsRelative. The default is 1 and if true then the Path
         includes a forward slash instead of a backslash. If IsRelative=1 then I use StringReplace as a quick fix
        *  Extension info is now saved with .xpi file extension e.g. "\extensions\mozrepl@hyperstruct.net.xpi  
        *  Tested with FF versions 29.x  but will likely work with other recent versions of FF. 
#ce
;===============================================================================

;[Example]
;$Result = _MozRepl_Detect()
;MsgBox(64, "Result", $Result)
 
Func _MozRepl_Detect($sProfile = "default", $bInstall = True , $sXPI = "https://addons.mozilla.org/firefox/downloads/file/205776/mozrepl-1.1.2-fx.xpi") ; Updated to point to addons.mozilla.org per mozrepl github
    If $sProfile = "" Then $sProfile = "default"
    
    Local $sIni_Path = @AppDataDir & "\Mozilla\Firefox\"
    Local $var = IniReadSectionNames($sIni_Path & "\profiles.ini")
    
    If @error Then
        MsgBox(4096, "", "Error occurred, probably no Firefox INI file.")
    Else
        For $i = 1 To $var[0]
          Local $Ini_ = IniRead($sIni_Path & "\profiles.ini", $var[$i], "Name", "Error")
          If $Ini_ = $sProfile Then
            Local $sPath_folder = IniRead($sIni_Path & "\profiles.ini", $var[$i], "Path", "Error") 
            Local $isRelative = Int( IniRead($sIni_Path & "\profiles.ini", $var[$i], "IsRelative", "Error"))    ;Read IsRelative key
            ExitLoop
          EndIf
        Next
    EndIf

If $bInstall Then
      If Not @OSArch = "X86" Then  ;  
        Local $sHKLM = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mozilla\Mozilla Firefox"  ;If it's a 64-bit OS then use the reg path below 
      Else
        $sHKLM = "HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox"
      EndIf
      
        Local $sFFVerKey = $sHKLM & "\" & RegEnumKey($sHKLM, 1) ; Assumes there's a single install of FF because this works for me, but might need to be expanded upon
        Local $sFFExe = RegRead($sFFVerKey & "\Main", "PathToExe")
      ; Local $sCommand = StringFormat('"%s" "%s"',$sFFExe, $sXPI)   ; Removed StringFormat as it's no longer necessary...?
        Local $sCommand = $sFFExe & " " & $sXPI
    EndIf

    If StringLeft($sPath_folder, 8) = "Profiles" And $isRelative = 1 Then
      $sPath_folder = StringReplace($sPath_folder, "/", "\", 0, 2)   ; Replace forward slash with backslash
        If FileExists($sIni_Path & $sPath_folder & "\extensions\mozrepl@hyperstruct.net.xpi") Then  ;Tacked on .xpi at the end because FF seems to handle differently now.
        Return 1
        Else
            If $bInstall Then Return Run($sCommand)
            Return 0
        EndIf
    Else
        If FileExists($sPath_folder & "\extensions\mozrepl@hyperstruct.net.xpi") Then
            Return 1
        Else
            If $bInstall Then Return Run($sCommand)
            Return 0
        EndIf
    EndIf
EndFunc   ;==>_MozRepl_Detect

Edit: I forgot to mention that if you want to configure MozRepl to start automatically without user intervention just append the following line to the user.js file in the FF profile directory:  user_pref("extensions.mozrepl.autoStart", true);  If the user.js file doesn't exist, simply create it, and mozrepl will be enabled when FF is restarted. The user.js takes precedence over the prefs.js file so please be aware that once you make this change, anyone using that profile will not be able to undo the setting via about:config.

Edited by Gonnosuke

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...