Jump to content

FF.au3 (V0.6.0.1b-10)


Stilgar
 Share

Recommended Posts

  • 2 weeks later...

I'm trying to evaluate how FF.au3 can help me but I'm a little lost. After getting the latest versions of FF.au3, FFEx.au3 and FF-Page_Analyzer.au3 on your site, I still get

ERROR: _FFFrameGetSelected(): undefined function.

Where can I get the missing file?

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

So I see that you introduced some event dispatching code in last August FF.au3 version.

New in the latest test-version:

_FFDispatchEvent($sElement, $sEventType = "change")

$sElement = Element or object from _FFXpath /_FFObj*

$sEventType = change|select|focus|blur|resize

The various event handlers that can exist are not automatically activated by the _FFForm functions (for example _FFFormRadioButton, _FFFormCheckBox, _FFFormOptionselect), though the _FFClick function actually fires a click event and so the existing onclick event handler are automatically activated with using _FFClick.

After some testing and experimenting, the way to use the _FFDispatchEvent is something like that (assuming my input field as some onchange event handler):

; set a value in an input field (onchange evant handler will NOT be activated)
_FFSetValue("smith", "input_text", "name")  
; so now we manually fire a "change" event on the same input field
$oSelect = _FFObjGet("input_text","name")
_FFDispatchEvent($oSelect, "change")

And the same to be done for the other inputs on which I could have some event handlers (radio buttons, checkboxes, selects...).

As my objective is to have a script with as few specific code as possible, I'd like to have the existing event handlers activated without having to add myself these calls to the _FFDispatchEvent.

So I took a look on your FF.au3 code and did some changes on my own to add this feature wher I need them. Here are the changes: maybe this is not the best or cleanest soluton, but it is curently suiting my needs. When you implement the feature in a future eversion of FFF.au3, I will be interesting in comparing your solution with mine...

Func _FFFormCheckBox($vBox, $bChecked = True, $iBoxNameIndex = 0, $sBoxMode = "index", $vForm = 0, $sFormMode = "index", $bCheckBox = True)
    ...
    _FFXPath(StringFormat("//form[%s]//input[@type='%s' and %s]", $sForm, $sType, $sCheckBox), $sCommand, 9)    
    If Not @error Then
        ;GJ start: send a "click" event on the targeted element  PROBLEM: CLICK is not allowed by FFDispatchEvent!!! 
        ; => using a modified version to allow it
        if $bCheckBox Then
            ; as the click WILL change the checbox status, we first execute the request, but with inverted status
            Local $sCommand = "checked=" & __FFB2S($bChecked==false)
            _FFXPath(StringFormat("//form[%s]//input[@type='%s' and %s]", $sForm, $sType, $sCheckBox), $sCommand, 9)    
            Local $sCommandSel = StringFormat("//form[%s]//input[@type='%s' and %s]", $sForm, $sType, $sCheckBox)
            Local $ogj = _FFXPath($sCommandSel, "", 9)  ; get a reference to the targeted object
            _FFDispatchEvent($ogj, "click")         ; and dispatch a click event on it
        Else
            Local $sCommandSel = StringFormat("//form[%s]//input[@type='%s' and %s]", $sForm, $sType, $sCheckBox)
            Local $ogj = _FFXPath($sCommandSel, "", 9)  ; get a reference to the targeted object
            _FFDispatchEvent($ogj, "click")         ; and dispatch a click event on it
        Endif
        ;GJ end
        Return 1
    Else
        SetError(@error)
        Return 0
    EndIf

EndFunc   ;==>_FFFormCheckBox

Func _FFFormOptionselect($vElement = 0, $sElementMode = "index", $vOption = 0, $sOptionMode = "index", $vForm = 0, $sFormMode = "index")
    ...
    Local $sCommand = StringFormat("//form[%s]//select[%s]//option[%s]", $sForm, $sElement, $sOption)
    _FFXPath($sCommand, "selected=true", 9)
    If Not @error Then
        ;GJ start: send a "change" event on the targeted element
        Local $sCommandSel = StringFormat("//form[%s]//select[%s]", $sForm, $sElement)
        Local $ogj = _FFXPath($sCommand, "", 9)     ; get a reference to the targeted object
        _FFDispatchEvent($ogj, "change")        ; and dispatch a change event on it
        ;GJ end 
        Return 1
    Else
        SetError(@error)
        Return 0
    EndIf

EndFunc   ;==>_FFFormOptionselect

Func _FFDispatchEvent($sElement, $sEventType = "change", $iKeyCode = 13)
    ...

    Switch $sEventType
        Case "change", "select", "focus", "blur", "resize"
            $sType = "Event"
        Case "keydown", "keypress", "keyup"
            $sType = "KeyboardEvent"
; GJ start
        Case "click"
            $sType = "MouseEvents"
; GJ end
        Case Else
            SetError(__FFError($sFuncName, $_FF_ERROR_InvalidValue, "(click|change|select|focus|blur|resize|keydown|keypress|keyup) $sEventType: " & $sEventType))
            Return 0
    EndSwitch
    ...
EndFunc   ;==>_FFDispatchEvent

Func _FFSetValue($sValue, $sElement, $sMode = "elements", $iIndex = 0)
    ...
    Local $sElementIn = $sElement   ;GJ
    Local $sModeIn = $sMode     ;GJ
    Local $iIndexIn = $iIndex   ;GJ 
    ...
    Local $sRetVal = _FFCmd($sElement & ".value='" & $sValue & "'") 
    If Not @error And $sRetVal <> "_FFCmd_Err" Then
        ;GJ start: trying to send a "change" event on the element item
        Local $ogj = _FFObjGet($sElementIn, $sModeIn, $iIndexIn)    ; get a reference to the targeted object
        _FFDispatchEvent($ogj, "change")        ; and dispatch a change event on it
        ;GJ end
        Return 1
    Else
        SetError(__FFError($sFuncName, $_FF_ERROR_NoMatch, "$sElement: " & $sElement))
        Return 0
    EndIf

EndFunc   ;==>_FFSetValue

Any comment will be appreciated.

Link to comment
Share on other sites

  • 3 weeks later...

I have a _FFLinkClick-problem: Look at this little programm;

#include <FF.au3>

;_FFStart('http://www.basko.at/')

Local $wait_seconds = 3

If _FFConnect() Then
    _FFOpenURL('http://www.basko.at/')
    Sleep($wait_seconds*1000)
    _FFLinkClick('click_problem/seite1','href')
    Sleep($wait_seconds*1000)
    _FFLinkClick('click_problem/seite2','href')
EndIf
Exit

The second click does not work. You may try it. The log of running the code above is:

_FFConnect: OS: WIN_VISTA WIN32_NT 6000 
_FFConnect: AutoIt: 3.3.4.0
_FFConnect: FF.au3: 0.6.0.1b-4
_FFConnect: IP: 127.0.0.1
_FFConnect: Port:   4242
_FFConnect: Delay:  2ms
_FFConnect: Socket:     588
_FFConnect: Browser:    Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)
__FFSendJavascripts: Sending functions to FireFox .......... done
_FFOpenURL: http://www.basko.at/
__FFSend: try{window.content.top.document.location.href='http://www.basko.at/'}catch(e){'_FFCmd_Err';};
__FFRecv: http://www.basko.at/
_FFLoadWait: .. loaded in 273ms
__FFSend: try{FFau3.WCD=window.content.top.document;}catch(e){'_FFCmd_Err';};
__FFRecv: [object XPCNativeWrapper [object HTMLDocument]] — {contentType: "text/html", addEventListener: function() {…}, title: "Basko von Gradenegg", forms: {…}, defaultView: {…}, characterSet: "ISO-8859-1"}
__FFSend: FFau3.xpath=null;try{FFau3.xpath=FFau3.WCD.evaluate("//a[contains(@href,'click_problem/seite1')]",FFau3.WCD,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;}catch(e){'_FFXPath_Error: '+e;};
__FFRecv: http://www.basko.at/click_problem/seite1.html
__FFSend: try{FFau3.simulateEvent(FFau3.xpath,'MouseEvents','click');}catch(e){'_FFCmd_Err';};
__FFRecv: 1
_FFLoadWait: .. loaded in 281ms
__FFSend: FFau3.xpath=null;try{FFau3.xpath=FFau3.WCD.evaluate("//a[contains(@href,'click_problem/seite2')]",FFau3.WCD,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;}catch(e){'_FFXPath_Error: '+e;};
__FFRecv: 
__FFSend: try{FFau3.simulateEvent(FFau3.xpath,'MouseEvents','click');}catch(e){'_FFCmd_Err';};
__FFRecv: -3
_FFClick ==> No match: $sElement: FFau3.xpath
>Exit code: 0    Time: 8.450

Commenting the first click and doing it by hand shows that the second links works too.

Edited by quercus
Link to comment
Share on other sites

I have problem with _FFLinkClick when click a link which is in a frame.

Html source:

<frameset class="frameset" rows="90,*" framespacing="0" frameborder="0">
  <frame name="topframe" src="http://www.yahoo.com" scrolling="no" noresize="noresize">
  <frame name="pathframe" src="http://www.google.com" scrolling="auto" noresize="noresize">
  <noframes>
    <p>Your browser does not support frames.</p>
  </noframes>
</frameset>

Sleep(3000)
   _FFFrameEnter(1)
   MsgBox(0,"Frame URL",_FFCmd(".location.href"))
   _FFLinkClick("about.html")

i want it to click "About Google" link, and in the console it returns

__FFSend: try{FFau3.simulateEvent(FFau3.xpath,'MouseEvents','click');}catch(e){'_FFCmd_Err';};
__FFRecv: 1
_FFLoadWait: . loaded in 11ms

seems the link is clicked successfully but in fact it's not :(

how to solve this problem? i heard some post said it's "cross domain" issue, anyway to bypass this issue?

Link to comment
Share on other sites

UDF to control FireFox (Flock) via MozRepl:

FF.au3 (V0.6.0.0b)

Changelog

Changes in V0.6.0.0b:

- Added: _FFWindowOpen: new parameter: $bLoadWait

- Added: _FFAu3Option / $_FF_SEARCH_MODE = 0 ; 0 = Substring / 1 = Compare

_FFImageClick

- Removed: _FFSetValueById, _FFSetValueByName ==> _FFSetValue

- Removed: _FFGetValueById, _FFGetValueByName ==> _FFGetValue

- Removed: _FFFormGetLength ==> _FFGetLength

- Removed: _FFTabGetLength ==> _FFGetLength

- Removed: _FFTableGetCell ==> _FFXpath

- Removed: _FFDisPatchKeyEvent ==> _FFDisPatchEvent

- Removed: _FFTabCloseAll ==> _FFTabClose

- Removed: _FFFormGetElementsLength: now only returns the DOM-standard length

- Removed: _FFRecord* functions and all additions for them in all functions

- Changed: _FFAction("copy"): works now only on the current frame

- Fixed: _FFFormGetElementsLength: Error Message

- Fixed: _FFDispatchEvent: Shortcut for elements

For compatibily for older scripts and more functions, please use this UDF:

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

Function list:

;_FFAction

;_FFClick

;_FFCmd

;_FFConnect

;_FFDialogWait

;_FFDisConnect

;_FFDispatchEvent

;_FFFormCheckBox

;_FFFormGetElementsLength

;_FFFormOptionselect

;_FFFormRadioButton

;_FFFormReset

;_FFFormSubmit

;_FFFrameEnter

;_FFFrameLeave

;_FFGetLength

;_FFGetObjectInfo

;_FFGetPosition

;_FFGetValue

;_FFImageClick

;_FFImageGetBySize

;_FFImageMapClick

;_FFIsConnected

;_FFLinkClick

;_FFLinksGetAll

;_FFLoadWait

;_FFLoadWaitTimeOut

;_FFObj

;_FFObjDelete

;_FFObjGet

;_FFObjNew

;_FFOpenURL

;_FFPrefGet

;_FFPrefReset

;_FFPrefSet

;_FFQuit

;_FFReadHTML

;_FFReadText

;_FFSearch

;_FFSetValue

;_FFStart

;_FFTabAdd

;_FFTabClose

;_FFTabDuplicate

;_FFTabExists

;_FFTabGetSelected

;_FFTabSetSelected

;_FFTableWriteToArray

;_FFWindowClose

;_FFWindowGetHandle

;_FFWindowOpen

;_FFWindowSelect

;_FFWriteHTML

;_FFXPath

Requirement(s).:

Latest Version of FireFox (Flock) and the AddOn MozRepl

!!!

Don't forget to start MozRepl.

FF-menu: Extras/Menu or check there "Activate on startup".

Documentation:

- English

- German

- Russian (by Valery)

- Englisch CHM, user-calltips ...

FF.au3 extensions:

- _FF_DM.au3 (UDF for the FireFox Download-Manager) [Forum]

- _FFEx.au3 (more functions and compatibly fixes for older scripts):

; _FFDisPatchKeyEvent

; _FFFormGetLength

; _FFGetValueById

; _FFGetValueByName

; _FFSetValueById

; _FFSetValueByName

; _FFTabCloseAll

; _FFTabGetLength

; _FFTableGetCell

; _FF_Call

; _FF_CookiesAllow

; _FF_CookiesDeny

; _FF_CookiesRemoveAll

; _FF_CookiesSetAccess

; _FF_EmptyCache

; _FF_EmptyCookies / _FF_CookiesRemoveAll

; _FF_EmptyHistory

; _FF_FormSetFileInput

; _FF_GetContentXY

; _FF_GetCurrentURL

; _FF_GetStatus

; _FF_GetTitle

; _FF_MozRepl_Detect

; _FF_ResetTitle

; _FF_TabGetAllTitles

; _FF_TabGetAllURLs

; _FF_TabReloadAll

UDFs for FireFox AddOns:

- _FF_FireFM [Forum]

- _FF_FoxBox.au3 [Forum]

- _FF_Screengrab.au3 [Forum]

Misc:

- _FF_AutoLogin [Forum]

- _FF_RecordForm [Forum]

- YouTube-API-Wrapper [Forum]

Additional software:

- FF-Page-Analyzer

Posted Image

Known problems:

- The _FFTab* functions doesn't work, if you have the FF-AddOn TabMixPlus installed (this AddOn seems to override some internal FF-functions)

More examples and stuff are on my homepage.

Stilgar

I am unable to use this functions, in my machine

I have firefox in my machine, and i have installed the plugin "MOZREPL" for the firefox

Can you please let me know the problem, why i am not able to use the functions

i am getting this message in the control panel

__FFWaitForRepl ==> Timeout: 10015ms > 10000ms $iTimeOut

Thanks in Advance

Edited by mmahima
Link to comment
Share on other sites

_FFLinkClick-Problem: Yes, for me, going back to the last 0.6.0.0 release solves my click problem.

could you please send the 0.6.0.0 version to me? i can't find anywhere to download it :(

my email is ininja999@gmail.com

thanks a lot:)

Link to comment
Share on other sites

  • 2 weeks later...

@GerardJ: Could You please make available the full code of Your enhancements shown above (_FFForm...)?

Here it is (sorry for the delay, I did not came here for quite a long time)

Of cours, I share with no guarantee: there may be problems, so if you can improve this code, don't hesitate.

I've added this warning at beginning of the file:

*****************************************************************

** THIS IS A MODIFIED, NON OFFICIAL VERSION

** THERE IS NO GUARANTEE MY CHANGES ARE VALID, OR WILL BE KEPT

** BY THE AUTHOR IN HIS NEXT RELEASES...

**

** I've added the minimum I needed to have working event handlers

** on the following:

** onclick for _FFFormRadioButtons, _FFFormCheckBoxes, _FFFormOptionselect

** onchange on _FFSetValue,

** (the onclick was already working on the _FFClick)

**

** my changes are identified with "GJ start" and "GJ end" comments

** or simply with my initals "GJ"

** and I did rename the original FF.au3 to FFgj.au3 to avoid any confusion.

**

*****************************************************************

FFgj.zip

Link to comment
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
 Share

  • Recently Browsing   0 members

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