Jump to content
Stilgar

FF.au3 (V0.6.0.1b-10)

Recommended Posts

Updated to V0.5.3.9b

Look at the first post for changes, please.

--------------------

@Leiif:

At first you must safe the FF.au3 as au3-file in your include-directory e.g.

c:\Program Files\AutoIt\include\FF.au3

If you wanna use it in your programm then "include" it like every other UDF e.g.

#include <FF.au3>

Expample:

#include <FF.au3>
_FFStart("http://example.com")

For reading the urls and informations from files look at the File*-functions please.

Other example:

#include <FF.au3>
_FFStart() ; just starting the browser

If _FFIsConnected() Then
  _FFOpenURL("http://ff-au3-example.thorsten-willert.de/") ; opens a webpage
  _FFSetValueByName("lname", "Name") ; insert your data into the input "Vorname" with the attribut name="lname"
  _FFFormSubmit() ; submits the formular
EndIf

--------------------

@LOULOU:

Select the window with _FFWindowSelect() - without parameters it uses the last opened window

Edited by Stilgar

Share this post


Link to post
Share on other sites

How can I convert this AutoIt IE Code to FF AutoIt functions..??

$GetFormTags = _IETagNameGetCollection($IE, 'FORM')
$NumFormTags = @extended
For $i = 0 to $NumFormTags - 1
    $Form = _IETagNameGetCollection($IE, 'FORM', $i)
         MsgBox(0,"", $Form.Name&@CRLF&$Form.Action)
Next

The simplest way would be this:

$aName = _FFXpath("//form", "name", 6)
$aAction = _FFXpath("//form", "action", 6)

For $i = 1 To $aName[0]
    MsgBox(0,"", $aName[$i] & @CRLF & $aAction[$i])
Next

Share this post


Link to post
Share on other sites

Does that do the same thing as my code does though.??

I need it to get all the Forms on a page, then MsgBox the ( Form.Name & Form.Action ) of each Form on that page..

Share this post


Link to post
Share on other sites

Does that do the same thing as my code does though.??

I need it to get all the Forms on a page, then MsgBox the ( Form.Name & Form.Action ) of each Form on that page..

Yes, it's the same thing.

Share this post


Link to post
Share on other sites

I'm having an issue with the _FFWindowGetHandle() function where is doesn't reset the title properly. For example:

#include <FF.au3>

If Not _FFIsConnected() And Not _FFConnect(Default, Default, 100) Then
    MsgBox(64, "", "Can't connect to FireFox!")
Else
    $result = _FFWindowSelect("www.google.com","href", False)
    MsgBox(0,'test',_FFCmd(".title"))
EndIf

This code returns "FFAU31347304041" instead of "Google" or "iGoogle".

I changed _FFWindowGetHandle as follows, which seems to fix the issue:

Func _FFWindowGetHandle()
    Local Const $sFuncName = "_FFWindowGetHandle"
    ; in the future to handle with XPCOM =#=
    Local $bErr = False
    Local $hWindow = ""

    BlockInput(1) ; =#=
    If Not @error Then
        Local $sTitle = _FFCmd(".title")
        Local $sTitleRnd = "FFAU3" & Random(1000000000, 9999999999, 1)
        _FFCmd(".title='" & $sTitleRnd & "'")
        Local $iMatchMode = AutoItSetOption("WinTitleMatchMode", 1)
        Sleep(500)
        $hWindow = WinGetHandle($sTitleRnd)
        If @error Then $bErr = True
        AutoItSetOption("WinTitleMatchMode", $iMatchMode)
;       _FFCmd("document.title=window.content.top.document.getElementsByTagName('title')[0].textContent")
        _FFCmd(".title='" & $sTitle & "'")
        ConsoleWrite("_FFWindowGetHandle: " & $hWindow & @CRLF)
    EndIf
    BlockInput(0)

    If $bErr Then SetError(__FFError($sFuncName, $_FF_ERROR_GeneralError))
    Return $hWindow
EndFunc   ;==>_FFWindowGetHandle

Thoughts?

Share this post


Link to post
Share on other sites

The simplest way would be this:

$aName = _FFXpath("//form", "name", 6)
$aAction = _FFXpath("//form", "action", 6)

For $i = 1 To $aName[0]
    MsgBox(0,"", $aName[$i] & @CRLF & $aAction[$i])
Next

so how would I set the input text of a form that had a certain string in its Form.Action..??

so say the Form.Action contains ".php" how would i set the Input.Text of that form to "123"

then untick all the checkboxes belonging to that form and then submit that form..??

Edited by cypher175

Share this post


Link to post
Share on other sites

@DanP2:

Reseting the title with this line:

_FFCmd("document.title=window.content.top.document.getElementsByTagName('title')[0].textContent")

is to avoid problems with different codepages.

But it seems there was something changed in latest FF-versions ...

I have fixed the problem in the latest test-version:

http://thorsten-willert.de/Themen/FFau3/Testversion/FF.au3

----

Your example would better look like this:

#include <FF.au3>

_FFConnect(Default, Default, 100)

If _FFIsConnected() Then
    $result = _FFWindowSelect("www.google.com","href", False)
    MsgBox(0,'test',_FFCmd(".title"))
Else
    MsgBox(64, "", "Can't connect to FireFox!")
EndIf

because _FFIsConnected are only usefull after the use of _FFConnect or _FFStart.

Or shorter:

#include <FF.au3>

If _FFConnect(Default, Default, 100) Then
    $result = _FFWindowSelect("www.google.com","href", False)
    MsgBox(0,'test',_FFCmd(".title"))
Else
    MsgBox(64, "", "Can't connect to FireFox!")
EndIf

so how would I set the input text of a form that had a certain string in its Form.Action..??

so say the Form.Action contains ".php" how would i set the Input.Text of that form to "123"

then untick all the checkboxes belonging to that form and then submit that form..??

_FFConnect()

If _FFIsConnected() Then
    $aName = _FFXpath("//form", "name", 6)
    $aAction = _FFXpath("//form", "action", 6)
    
    For $i = 1 To $aName[0]
        MsgBox(0,"", $aName[$j] & @CRLF & $aAction[$j])
        If $aAction[$j] = "/file.php" Then
            _FFXpath("//form[" & $j & "]//input[@type='checkbox']", "checked=false", 6) ; unchecking ALL checkboxes in this form
            _FFSetValueByName("NameOfTheInput", "123") ; or
            _FFSetValueById("IDOfTheInput", "123")
            _FFFormSubmit($i-1) ; -1 because of the DOM-index from 0-n
            ExitLoop
        EndIf
    Next
EndIf

If you don't wanna search the IDs and names in the HTML-Source you can use this function:

http://www.autoitscript.com/forum/index.php?showtopic=103270

Edited by Stilgar

Share this post


Link to post
Share on other sites

I have fixed the problem in the latest test-version:

http://thorsten-willert.de/Themen/FFau3/Testversion/FF.au3

Yes, looks much better. Thanks!

Using the _IEAttach function, I can address a specific tab by URL. I've tried using _FFWindowSelect, but it only succeeds if the desired tab is already selected. Is there a way to do this using the existing architecture?

FWIW, I played around with this over the weekend and ended up adding the function FFau3.SearchTabURL. I then modified some of the _FFTab* functions to allow for sMode = 'href'. If you're interested, I can send you the modified source.

Dan

Share this post


Link to post
Share on other sites

@Stilgar..

How would I check the state (checked=true/false) of a CheckBox by its NAME..??

And then do something based on its Checked State..??

also is there a function like .ScrollIntoView() that focuses the webpage on a certain element..??

Edited by cypher175

Share this post


Link to post
Share on other sites

@DanP2:

In _FFWindowSelect I forget to build in the selection by URL, it's the same like selection by tab-label.

Yes you can send me the modified source, please.

Right the @error from _FFWindowSelect isn't always correct, but it the function returns 0 if it fails, otherwise 1.

@cypher175:

Checkbox:

Currently only via xpath:

$Checked = _FFXpath("//input[@type='checkbox' and @name='name'], "checked", 9)

I change this in the next version.

Scrolling:

You can use this function:

http://www.thorsten-willert.de/Themen/FFau3/Beispiele/FFElementGetPosition.au3

to get the position ot the element and then scroll to it via:

_FFAction("ScrollXY", $iX, $iY)

@LOULOU:

Strange, here it works and I changed nothing in this function.

Have you any error messages in your console-output?

Share this post


Link to post
Share on other sites

@DanP2:

Thank you!

----

Is there any FF function to do this: _IEAction($IE, "stop") to stop FF that is still loading a page..??

_FFAction("stop")

Share this post


Link to post
Share on other sites

@Stiglar:

Is there any other _FFCmd's like the ones below to Clear "Everything" from FF's "Recent History"..??

; Cookies
_FFCmd("Components.classes['@mozilla.org/cookiemanager;1'].getService(Components.interfaces.nsICookieManager).removeAll();")

; History
_FFCmd("Components.classes['@mozilla.org/browser/nav-history-service;1'].getService(Components.interfaces.nsIBrowserHistory).removeAllPages();")

; Cache
_FFCmd("Ci=Components.interfaces;Components.classes['@mozilla.org/network/cache-service;1'].getService(Ci.nsICacheService).evictEntries(Ci.nsICache.STORE_ANYWHERE);")

Share this post


Link to post
Share on other sites

Is there any other _FFCmd's like the ones below to Clear "Everything" from FF's "Recent History"..??

I'm not sure what you mean. Do you searching anything other then the second _FFCmd(..) ?

@Ontosy:

MozRepl doesn't work with Thunderbird.

But you can ask the author of it if he can change this:

http://groups.google.de/group/mozlab?hl=de

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

×
×
  • Create New...