Jump to content

Automate firefox


Bert
 Share

Recommended Posts

  • Replies 251
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I can try do add something, but I'm not sure if it's possible without toooo much work.

Here is a other example for the FF.au3. You can not only control the browser - all AddOns, too!

Here's an example for FireFM:

#region Includes
#include <Array.au3>
#include <FF.au3>
#endregion Includes

$Socket = _FFConnect()

If $Socket > -1 Then
    _FF_FireFM_Player($Socket, "Play")
    If Not @error Then
        sleep(10000)

        ; set volume
        _FF_FireFM_SetVolume($Socket, 70)

        ; get title information
        $a = _FF_FireFM_GetTitleInfo($Socket)
        _ArrayDisplay($a)
        sleep(10000)

        ; skip the current song
        _FF_FireFM_Player($Socket)

        ; stop playing
        sleep(10000)
        _FF_FireFM_Player($Socket, "Stop")
    EndIf
EndIf

Exit


; #FUNCTION# ===================================================================
; Name ..........: _FF_FireFM_GetTitleInfo
; Description ...: FireFM informations of the current title
; AutoIt Version : V3.3.0.0
; Requirement(s).: FF.au3 / MozRepl
; Syntax ........: _FF_FireFM_GetTitleInfo(ByRef $Socket)
; Parameter(s): .: $Socket      - TCP Socket
; Return Value ..: Success      - 2 dim Array with the title information: [discription][info]
;                               - [0] = id
;                               - [1] = location
;                               - [2] = title
;                               - [3] = recording
;                               - [4] = albumTitle
;                               - [5] = artist
;                               - [6] = duration
;                               - [7] = imagePath
;                               - [8] = trackAuth
;                               - [9] = albumID
;                               - [10] = artistID
;                               - [11] = artistURL
;                               - [12] = albumURL
;                               - [13] = trackURL
;                               - [14] = buyTrackURL
;                               - [15] = buyAlbumURL
;                               - [16] = freeTrackURL
;                               - [17] = startTime
;                  Failure      - Array [0][0]=0
;                  @ERROR       -
; Author(s) .....: Thorsten Willert
; Date ..........: Wed Feb 11 11:46:19 CET 2009 @490 /Internet Time/
; ==============================================================================
Func _FF_FireFM_GetTitleInfo(ByRef $Socket)
    Local $aInfo, $aRet[1][1], $aTmp, $bPlaying
    Local $iTicks, $iHours, $iMins, $iSecs

    $bPlaying = _FFSetGet($Socket, "FireFM.Player.isPlaying;")
    If @error Or Not $bPlaying Then
        SetError(1)
        Return $aRet[0][0] = 0
    EndIf

    $aInfo = StringSplit(_FFSetGet($Socket, "repl.inspect(FireFM.Player.track);"), @crlf, 2)
    If Not @error And IsArray($aInfo) And Ubound($aInfo) > 18 Then
        ReDim $aRet[18][2]

        For $i = 0 To 17
            $aTmp = StringRegExp($aInfo[$i], "<object>.(.*?)=(.*?)$", 3)
            $aRet[$i][0] = $aTmp[0]
            $aRet[$i][1] = $aTmp[1]
        Next

        $iTicks = Round($aRet[6][1] / 1000)
        $iHours = Int($iTicks / 3600)
        $iTicks = Mod($iTicks, 3600)
        $iMins = Int($iTicks / 60)
        $iSecs = Round(Mod($iTicks, 60))
        If $iHours > 0 Then
            $aRet[6][1] = $iHours & ":" & $iMins & ":" & $iSecs
        Else
            $aRet[6][1] = $iMins & ":" & $iSecs
        EndIf
    Else
        SetError(1)
        Return $aRet[0][0] = 0
    EndIf

    Return $aRet
EndFunc   ;==>_FF_FireFM_GetTitleInfo

; #FUNCTION# ===================================================================
; Name ..........: _FF_FireFM_Player
; Description ...: FireFM Player
; AutoIt Version : V3.3.0.0
; Requirement(s).: FF.au3 / MozRepl
; Syntax ........: _FF_FireFM_Player(ByRef $Socket[, $sAction = "skip"])
; Parameter(s): .: $Socket      - TCP Socket
;                  $sAction     - Optional: (Default = "skip") : play, stop, skip
; Return Value ..: Success      - Status playing 1/0
;                  Failure      - -1
;                  @ERROR       -
; Author(s) .....: Thorsten Willert
; Date ..........: Wed Feb 11 11:57:17 CET 2009 @498 /Internet Time/
; ==============================================================================
Func _FF_FireFM_Player(ByRef $Socket, $sAction = "skip")
    Local $iCount = 0
    Local $bPlaying = _FFSetGet($Socket, "FireFM.Player.isPlaying;")
    If @error Then
        SetError(1)
        Return -1
    EndIf

    Switch $sAction
        Case "stop"
            _FFSetGet($Socket, "FireFM.Player.stop();")
        Case "play"
            If Not $bPlaying Then
                _FFSetGet($Socket, "FireFM.Player.play();")
                While Not _FFSetGet($Socket, "FireFM.Player.isPlaying;") And $iCount < 5000
                    Sleep(250)
                    $iCount += 250
                Wend
            EndIf
        Case "skip"
            If $bPlaying Then
                _FFSetGet($Socket, "FireFM.Player.skip();")
                While Not _FFSetGet($Socket, "FireFM.Player.isPlaying;") And $iCount < 5000
                    Sleep(250)
                    $iCount += 250
                Wend
            EndIf
        Case Else
            SetError(1)
            Return -1
    EndSwitch

    Return _FFSetGet($Socket, "FireFM.Player.isPlaying;")
EndFunc   ;==>_FF_FireFM_Player

; #FUNCTION# ===================================================================
; Name ..........: _FF_FireFM_SetVolume
; Description ...: FireFM Volume
; AutoIt Version : V3.3.0.0
; Requirement(s).: FF.au3 / MozRepl
; Syntax ........: _FF_FireFM_SetVolume(ByRef $Socket[, $iVolume = 50])
; Parameter(s): .: $Socket      - TCP Socket
;                  $iVolume     - Optional: (Default = 50) : 0-100
; Return Value ..: Success      - Volume 0-100
;                  Failure      - -1
;                  @ERROR       -
; Author(s) .....: Thorsten Willert
; Date ..........: Wed Feb 11 11:57:25 CET 2009 @498 /Internet Time/
; ==============================================================================
Func _FF_FireFM_SetVolume(ByRef $Socket, $iVolume = 50)

    _FFSetGet($Socket, "FireFMChrome.UIState._setVolume(" & $iVolume & ");")
    If @error Then
        SetError(1)
        Return -1
    EndIf

    Return _FFSetGet($Socket, "FireFM.Player.volume;")
EndFunc   ;==>_FF_FireFM_SetVolume

In the future are more examples and updates are there:

FF.au3 Examples

Edited by Stilgar
Link to comment
Share on other sites

I've uploaded a new version:

V0.3.6.1b

Added some new functions in the last versions:

; returns the text or html of a table cell
_FFTableGetCell(ByRef $Socket, $vTable, $iColumn, $iRow[, $sMode = "index"[, $sReturnMode = "text"[, $bCompress = true]]])

; returns the value of a XPath query
_FFGetValueByXPath(ByRef $Socket, $sQuery[, $sReturnType = "string"[, $iFilter = 1]])

; duplicates a tab
_FFTabDuplicate(ByRef $Socket[, $vTab = -1[, $sMode = "index"[, $bToFront = false]]])

Changelog

Link to comment
Share on other sites

Sorry I don't know how to explain that, do you know Imacros, a great automatic addon for Firefox, it can extract text in the region defined.

https://addons.mozilla.org/en-US/firefox/addon/3863

I think you can use _FFGetValueByXPath to do this e.g.:

#include <FF.au3>

$Socket = _FFConnect()

If $Socket > -1 Then
    _FFTabAdd($Socket, "http://ff-au3-example.thorsten-willert.de/")

    MsgBox(64, "Fieldset-Legend:", _FFGetValueByXPath($Socket, "//form[@id='Programmiersprache']/fieldset/legend"))

EndIf

The XPath queries can you generate with the AddOns XPather or FireBug.

https://addons.mozilla.org/de/firefox/addon/1192

https://addons.mozilla.org/de/firefox/addon/1843

Edited by Stilgar
Link to comment
Share on other sites

I think you can use _FFGetValueByXPath to do this e.g.:

#include <FF.au3>

$Socket = _FFConnect()

If $Socket > -1 Then
    _FFTabAdd($Socket, "http://ff-au3-example.thorsten-willert.de/")

    MsgBox(64, "Fieldset-Legend:", _FFGetValueByXPath($Socket, "//form[@id='Programmiersprache']/fieldset/legend"))

EndIf

The XPath queries can you generate with the AddOns XPather or FireBug.

https://addons.mozilla.org/de/firefox/addon/1192

https://addons.mozilla.org/de/firefox/addon/1843

Thank you ! Great ! :)
Link to comment
Share on other sites

I've downloaded your newest FF.au3 and in fact there is no _FFFrameGetSelected() function :)

Strange:

Here's a"screenshot" from the latest version I've uploaded:

Posted Image

There is the _FFFrameGetSelected function and you must have some more informations in the console if you made a new connection to FF.

Just try it again, please :)

FF.au3

Edited by Stilgar
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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