*Bump*
FF-Management - FireFox.au3
-
-
Nur nicht hetzen
Ich werde im laufe der Woche eine überarbeitete Version herausbringen. Mit den Frames muß ich mir noch eine Lösung ausdenken.
Grüße
Stilgar -
-
Ich hätte hier eine Erweiterung für den Parameter -no-remote, der das Starten mehrerer Profile zulässt:
Spoiler anzeigen
[autoit]; ==============================================================================
[/autoit] [autoit][/autoit] [autoit]
; Function ......: _FFStart
; Description ...:
; Parameter(s) ..: $sURL = "about:blank" Start URL
; $sProfile = "default" UserProfile
; $bHide = false
; $iNewProcess = 1 0 = Connect to existing process
; 1 = Start new process
; 2 = Connect to an existing process on failure start a new process
; +5 = Use the -no-remote param to allow multiple Profiles
; $IP = 127.0.0.1
; $iPort = 4242
; Requirement ...:
; Return values .: Success - Socket
; Failure - -1
; User CallTip: .: ([$sURL = "about:blank"[, $sProfile = "default"[, $iMode = 1[, $bHide = False[, $IP = "127.0.0.1"[, $iPort = 4242]]]]]])
; Author(s) .....: Thorsten Willert
; Date ..........: 01. September 2007
; Note(s) .......:
; ==============================================================================
Func _FFStart($sURL = "about:blank", $sProfile = "default", $iMode = 1, $bHide = False, $IP = "127.0.0.1", $iPort = 4242)
Local $noRemote = False
If Not __FFIsIP($IP) Then
SetError(__FFError("_FFStart", $_FF_ERROR_InvalidDataType, $IP))
Return -1
EndIf
If Not __FFIsPort($iPort) Then
SetError(__FFError("_FFStart", $_FF_ERROR_InvalidDataType, $iPort))
Return -1
EndIf
If Not __FFIsURL($sURL) Then
SetError(__FFError("_FFStart", $_FF_ERROR_InvalidDataType, $sURL))
Return -1
EndIfLocal $Socket = -1
[/autoit] [autoit][/autoit] [autoit]
If $iMode >=5 Then
$iMode -= 5
$noRemote = True
EndIf
Switch $iMode
Case 0
If ProcessExists($_FF_PROC_NAME) Then $Socket = _FFConnect($IP, $iPort)
Case 1
__FFStartProcess($sProfile, $bHide,60000,$noRemote)
If ProcessExists($_FF_PROC_NAME) Then $Socket = _FFConnect($IP, $iPort)
Case 2
$Socket = _FFConnect($IP, $iPort, 3000)
If $Socket = -1 Then
__FFStartProcess($sProfile, $bHide,60000,$noRemote)
If ProcessExists($_FF_PROC_NAME) Then $Socket = _FFConnect($IP, $iPort)
EndIf
Case Else
Return -1
EndSwitchIf $Socket <> -1 Then
[/autoit] [autoit][/autoit] [autoit]
Sleep(2000)
_FFOpenURL($Socket, $sURL)
EndIfReturn $Socket
[/autoit][autoit]
EndFunc ;==>_FFStart; ==============================================================================
[/autoit] [autoit][/autoit] [autoit]
; Function ......: __FFStartProcess
; Description ...:
; Parameter(s) ..: $sProfile = "default"
; $bHide = False
; $iTimeOut = 60000
; Requirement ...:
; Return values .: Success - 1
; Failure - 0
; User CallTip: .: ([$sProfile = "default"[, $bHide = false[, $iTimeOut=60000]]])
; Author(s) .....: Thorsten Willert
; Date ..........: 1. September 2007
; Note(s) .......:
; ==============================================================================
Func __FFStartProcess($sProfile = "default", $bHide = False, $iTimeOut = 60000,$noRemote=0)If $sProfile Then
[/autoit] [autoit][/autoit] [autoit]
$sProfile = ' -P "' & $sProfile & '"'
Else
$sProfile = ' -P "default"'
EndIf
If $noRemote Then
$noRemote = " -no-remote"
Else
$noRemote = ""
EndIf
Local $sHKLM = "HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox"
Local $sVersion = RegRead($sHKLM, "CurrentVersion")
Local $sFFExe = RegRead($sHKLM & "\" & $sVersion & "\Main", "PathToExe")If Not $bHide Then
[/autoit] [autoit][/autoit] [autoit]
Run('"' & $sFFExe & '"' & $noRemote & ' -repl' & $sProfile) ; starting with MozRepl
Else
Run('"' & $sFFExe & '"' & $noRemote & ' -repl' & $sProfile, "", @SW_HIDE)
EndIf
If @error Then
SetError(__FFError("__FFStartProcess", $_FF_ERROR_GeneralError, "FireFox.exe not found in: " & $sFFExe))
Return 0
EndIfLocal $iTimeOutTimer = TimerInit()
[/autoit] [autoit][/autoit] [autoit]
While 1
Sleep(1000)
If ProcessExists($_FF_PROC_NAME) Then ExitLoop
If (TimerDiff($iTimeOutTimer) > $iTimeOut) Then
SetError(__FFError("__FFStartProcess", $_FF_ERROR_Timeout, "FireFox process not exists: " & $_FF_PROC_NAME))
Return 0
EndIf
WendIf $_FF_COM_TRACE Then ConsoleWrite("__FFStartProcess: " & $sFFExe & '" -repl' & $sProfile & @CRLF)
[/autoit] [autoit][/autoit] [autoit]Return 1
[/autoit]
EndFunc ;==>__FFStartProcess -
@progandy:
Danke für den Hinweis. Werde ich mal so (oder ähnlich) übernehmen. -
Wer nun unbedingt jetzt schon aus Frames zugreifen möchte, kann sich über _FFSetGet z.B.: folgende Sachen basteln:
QuellText-Abfrage:
content.frames[0].document.body.innerHTMLLocation:
content.frames[0].document.location.hrefTitel:
content.frames[0].document.titleLinks:
content.frames[0].document.links[0].hrefusw.
im Prinzip alles wie gehabt, nur daß zwischen dem Objekt "content" und "document" noch der Frame angeben wird.Wem das zu viel ist, kann in MozLab auch zu dem entsprechenden Objekt wechseln per:
[autoit]_FFSetGet($Socket,"repl.enter(content.frames[0].document)")
[/autoit]dann beziehen sich alle folgende Aufrufe darauf, also
[autoit]_FFSetGet($Socket,"title")
[/autoit]
liefert dann den Titel."Zurück" kommt man wieder per:
[autoit]_FFSetGet($Socket,"repl.home()")
[/autoit]Viel Spaß
Stilgar -
Stilgar, YMMD/YMMW/YMMM/YMMY
genial
wäre nie darauf gekommen
hatte immmer nur "content.document.frames ..."
-
Es gibt eine neue Testversion:
http://www.thorsten-willert.de/Themen/AutoIt-…tversion/FF.au3Und eine Seite zum Ausprobieren des nachfolgenden Testprogramms:
http://thorsten-willert.de//Themen/AutoIt-FF.au3/test.html
(die wird noch ausgebaut und in der Online-Hilfe verwendet)Beispiel für die Funktion "_FFFormCheckBox":
Spoiler anzeigen
[autoit]#region Includes
[/autoit] [autoit][/autoit] [autoit]
#include <FF.au3>
#endregion Includes$Socket = _FFStart("http://thorsten-willert.de/Themen/AutoIt-FF.au3/test.html")
[/autoit] [autoit][/autoit] [autoit]_FFFormCheckBox($Socket, "salami", true, -1, "value","Pizza","name")
[/autoit] [autoit][/autoit] [autoit]
sleep(500)
_FFFormCheckBox($Socket, "zutat", true, 1, "name",1,"index")
sleep(500)
_FFFormCheckBox($Socket, 0, true, 3, "index",1,"index")
sleep(1000)
_FFFormCheckBox($Socket, "z2", false, -1, "id","Pizza","name")_FFAction($Socket,"Alert","Ende des Beispiels.")
[/autoit] [autoit][/autoit] [autoit]_FFQuit($Socket)
[/autoit]
Die Verzögerungen sind nur drin, damit auch was siehtPassender Ausschnitt aus dem HTMl-Quelltext:
Spoiler anzeigen
PHP<form action="" methode="" name="Pizza" id="frm2"> <fieldset> <legend>Kreuzen Sie die gewünschten Zutaten an:</legend> <input type="checkbox" name="zutat" id="z1" value="salami"> Salami<br> <input type="checkbox" name="zutat" id="z2" value="pilze"> Pilze<br> <input type="checkbox" name="zutat" id="z3" value="sardellen"> Sardellen </fieldset> </form>
[EDIT] Funktion nochmal überarbeitet; damit sollte man nun jede erdenkliche CheckBox ansprechen können
Grüße Stilgar
-