Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

FF.au3 (V0.6.0.1b-10)


  • Please log in to reply
641 replies to this topic

#101 Stilgar

Stilgar

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 423 posts

Posted 10 August 2009 - 07:29 AM

Hi, I can't do with this :
<input type="file" size="35" name="upfile"/>

Right, because _FFObj is searching the attribute "value", so it fails at this code.
But you can do this
_FFXpath("//input[@type='file' and @name='upfile']","",9) _FFObj("xpath.value='c:\\text.txt'")

or this:
_FFXpath("//input[@type='file' and @name='upfile']","value='c:\\text.txt'",9)








#102 GerardJ

GerardJ

    Seeker

  • Active Members
  • 16 posts

Posted 10 August 2009 - 03:31 PM

Here is a new question (maybe a dumb one, but...)

How can we call a javascript function, defined in the current HTML page?

I thought it should be as simple as
_FFCmd("test()")

if the function in the page is defined as
<br /> <script type="text/javascript"><br />     function test(){<br />         alert("SIMPLE TEST");<br />     }<br /> </script><br />


But I can't figure how to make this work. Always getting a "__FFRecv: _FFCmd_Err" error message in the console
Can anybody help please?

#103 Stilgar

Stilgar

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 423 posts

Posted 10 August 2009 - 03:47 PM

Here is a new question (maybe a dumb one, but...)

How can we call a javascript function, defined in the current HTML page?

I thought it should be as simple as
_FFCmd("test()")

if the function in the page is defined as

<br /> <script type="text/javascript"><br />     function test(){<br />         alert("SIMPLE TEST");<br />     }<br /> </script><br />


But I can't figure how to make this work. Always getting a "__FFRecv: _FFCmd_Err" error message in the console
Can anybody help please?

If you only send "test()" then the function is searched in the window-context.
This one works:
_FFCmd("content.wrappedJSObject.test()")

look also there:
https://developer.mozilla.org/en/wrappedJSObject

#104 Rishodi

Rishodi

    Seeker

  • Active Members
  • 13 posts

Posted 10 August 2009 - 10:09 PM

I've been using IE.au3 for a while and am now trying to learn how to do all of the same things I need to do with FF.au3. I'm having some trouble figuring out how to retrieve some element properties like innerHtml, because the returned value appears to be the empty string no matter what I try. The code segment I'm currently running is this:

Local $splashDiv = _FFObjGet("isc-login-swoosh", "class") MsgBox(0, "", _FFCmd(".getElementsByClassName('isc-login-swoosh')[0].innerHtml")) Local $array = _FF_ElementGetPosition("getElementsByClassName('isc-login-swoosh')[0]") If (@Error == 0) Then MsgBox(0, "", $array[0] & ", " & $array[1])


Running from SciTE, this is the output I get to the console:

__FFSend: try{window.content.frames["top"].document.getElementsByClassName('isc-login-swoosh')[0]?1:0;}catch(e){'_FFCmd_Err';}; __FFRecv: 1 __FFSend: try{window.content.wrappedJSObject.frames["top"].document.getElementsByClassName('isc-login-swoosh')[0].innerHtml}catch(e){'_FFCmd_Err';}; __FFRecv: __FFSend: try{repl.inspect(FFau3.findPos)}catch(e){'_FFCmd_Err';}; __FFRecv: <undefined> is empty __FFSend: try{FFau3.findPos=function findPos(obj){var curleft=curtop=0;if(obj.offsetParent){do{curleft+=obj.offsetLeft;curtop+=obj.offsetTop;}while(obj=obj.offsetParent);return curleft+' '+curtop;}}}catch(e){'_FFCmd_Err';}; __FFRecv: function() {…} __FFSend: try{FFau3.findPos(content.document.getElementsByClassName('isc-login-swoosh')[0])}catch(e){'_FFCmd_Err';}; __FFRecv: 490 256


So I can confirm that the element exists and I can get its position using the _FF_ElementGetPosition() function. Using Firebug, I've also checked that the innerHtml property should not be empty, and I have code using IE.au3 that returns the innerHtml property as expected. What gives? What am I doing wrong?

#105 GerardJ

GerardJ

    Seeker

  • Active Members
  • 16 posts

Posted 11 August 2009 - 07:56 AM

If you only send "test()" then the function is searched in the window-context.
This one works:
_FFCmd("content.wrappedJSObject.test()")

look also there:
https://developer.mozilla.org/en/wrappedJSObject

Thank you, this syntax is working.

So the question was not so dumb I thought, since I never heard of that (requires knowing on Mozilla internals, which may not be common knowledge for those just willing to use the FF package)

#106 Stilgar

Stilgar

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 423 posts

Posted 11 August 2009 - 07:57 AM

@Rishodi:
All attributes and methodes from DOM/Javascript are casesensitiv.
I think you want the value from "innerHTML" and not from "innerHtml".
https://developer.mozilla.org/en/DOM/element.innerHTML

You can see there:
__FFSend: try{window.content.frames["top"].document.getElementsByClassName('isc-login-swoosh')[0]?1:0;}catch(e){'_FFCmd_Err';}; __FFRecv: 1

that the element is found, but there's no attribute "innerHtml"

You can write this a bit simpler if you using Xpath instead of objects:
$sInnerHTML = _FFXpath("//*[@class='isc-login-swoosh']","innerHTML",9) ; gets the innerHTML from the first element with the class 'isc-login-swoosh'


[EDIT]
@GerardJ:
Yes, but normaly you don't have to know the internals, or are the normal functions in the FF.au3 not enough?

Edited by Stilgar, 11 August 2009 - 10:11 AM.


#107 GerardJ

GerardJ

    Seeker

  • Active Members
  • 16 posts

Posted 11 August 2009 - 04:40 PM

@GerardJ:
Yes, but normaly you don't have to know the internals, or are the normal functions in the FF.au3 not enough?


You are probably right, I had to activate this javascript function because the onchange event on the form select I was testing is not yet managed by FF.au3.
But I'm sure we could find some cases where it could be useful, anyway, to activate a javascript function defined inside a page we are managing with FF.au3, so it might be worth adding such an example inside the _FFCmd documentation.

#108 Rishodi

Rishodi

    Seeker

  • Active Members
  • 13 posts

Posted 11 August 2009 - 05:34 PM

@Rishodi:
All attributes and methodes from DOM/Javascript are casesensitiv.
I think you want the value from "innerHTML" and not from "innerHtml".
https://developer.mozilla.org/en/DOM/element.innerHTML

Ah-ha! I had become so accustomed to automating IE within AutoIt that I became indifferent to the case sensitivity of the DOM. That was indeed my problem. D'oh! As for XPath, I was just introduced to it, so I appreciate the example. Thanks for your help!

#109 ValeryVal

ValeryVal

    Dig the way

  • Active Members
  • PipPipPipPipPipPip
  • 461 posts

Posted 13 August 2009 - 11:38 AM

@Stilgar:
Thank you for your FF.au3

Now AFireFox_Full can manage to SQLite3 DBs by "SQLite Manager Add on" for Firefox.

See photo of doing this on
AutoItGroup message
or in body of
this message.
The point of world view

#110 coolwulf

coolwulf

    Seeker

  • New Members
  • 1 posts

Posted 13 August 2009 - 07:06 PM

How can I use FF.au3 to clear Firefix History/cookies etc?

#111 Stilgar

Stilgar

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 423 posts

Posted 13 August 2009 - 09:23 PM

How can I use FF.au3 to clear Firefix History/cookies etc?


; 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);")


Look also at:
https://developer.mozilla.org/en/nsICookieManager
https://developer.mozilla.org/en/nsIBrowserHistory
https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsICacheService

Edited by Stilgar, 13 August 2009 - 09:25 PM.

  • MikahS likes this

#112 Rishodi

Rishodi

    Seeker

  • Active Members
  • 13 posts

Posted 17 August 2009 - 09:27 PM

I haven't been able to find useful information on this anywhere, so I wonder if anyone here could help me. I'm trying to use the DOM to find the relative position of a window object to the screen, or to the Firefox browser window. It's simple enough to find the size of the browser window (window.outerWidth/outerHeight) and its position relative to the screen (window.screenX/screenY), as well as the size of any window object (window.innerWidth/innerHeight) and the size of the screen (window.screen.width/height). However, I can't figure out how to find the position of a window object relative to the screen, or relative to the browser window. I'm sure everyone can see how useful this would be for an AutoIt script.

IE makes this easy with the non-standard window object properties screenLeft and screenTop, for which I have found no similar properties in Firefox. Is there any other way I could use to find the relative position of a window object in Firefox, or to find the size of all the browser toolbars, since that's basically what my request amounts to? If not, I may have to resort to a nasty workaround.

#113 Stilgar

Stilgar

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 423 posts

Posted 17 August 2009 - 10:19 PM

I haven't been able to find useful information on this anywhere, so I wonder if anyone here could help me. I'm trying to use the DOM to find the relative position of a window object to the screen, or to the Firefox browser window. It's simple enough to find the size of the browser window (window.outerWidth/outerHeight) and its position relative to the screen (window.screenX/screenY), as well as the size of any window object (window.innerWidth/innerHeight) and the size of the screen (window.screen.width/height). However, I can't figure out how to find the position of a window object relative to the screen, or relative to the browser window. I'm sure everyone can see how useful this would be for an AutoIt script.

IE makes this easy with the non-standard window object properties screenLeft and screenTop, for which I have found no similar properties in Firefox. Is there any other way I could use to find the relative position of a window object in Firefox, or to find the size of all the browser toolbars, since that's basically what my request amounts to? If not, I may have to resort to a nasty workaround.


I'm not sure what you searching for. What you wanna do with this positions?
Or is there anything you looking for:
https://developer.mozilla.org/en/DOM/window

Aren't window.screenX/Y and window.screenLeft/Right the same?
http://www.javascriptkit.com/domref/windowproperties.shtml

#114 LOULOU

LOULOU

    loulou

  • Active Members
  • PipPipPipPipPipPip
  • 484 posts

Posted 18 August 2009 - 06:09 AM

Posted Image Hi all,
Here is an helpFile FF3.chm for Firefox automation which is an adaptation of Stilgar's helpfile on his web
For safety reason you have to rename FF3.txt to FF3.chm
The forum doesn't allow transmitting a CHM File
Best Regards

Complementary information :
1 - To download this attachments you have to click on right button of your mouse and choosing "Saving target on"
Renaming FF3.txt in FF3.chm
2- When launching your chm files when the dialogbox appear unckeck "Always asking before opening file" and after click on OK , your chm file will be recognize like an help file by the system


Edited by LOULOU, 18 August 2009 - 07:14 AM.


#115 dmob

dmob

    Polymath

  • Active Members
  • PipPipPipPip
  • 237 posts

Posted 18 August 2009 - 06:20 AM

Posted Image Hi all,
Here is an helpFile FF3.chm for Firefox automation which is an adaptation of Stilgar's helpfile on his web
For safety reason you have to rename FF3.txt to FF3.chm
The forum doesn't allow transmitting a CHM File
Best Regards


Your attachment just opens up some garbage:
ITSF���`������Ä±é¢ ��ý|ª{О � É"æìý|ª{О � É"æì`��������������x�������T@������Ì@������þ�������Ì�������������ITSP���T���
����������������������ÿÿÿÿ��� ��j’].!Нù� É"æìT���ÿÿÿÿÿÿÿÿÿÿÿÿPMGL^�������ÿÿÿÿ���/���/#IDXHDRÒÇ` �/#ITBITS��� /#STRINGSÓ‡Z//#SYSTEM�ƒ~¡8/#TOPICSÒç`‰@/#URLSTRÒø0*/#URLTBLÒñ ‡ /#WINDOWSÒ°qL /$FIftiMain�� /$OBJINSTÒ²E•/$WWAssociativeLinks/���/$WWAssociativeLinks/PropertyÒ²A/$WWKeywordLinks/���/$WWKeywordLinks/PropertyÒ²=/_FFAction.htmî·/_FFAction.php_fichiers/���#/_FFAction.php_fichiers/default.css‘ˆ!š//_FFAction.php_fichiers/injection_graph_func.js‘¢5ñ

#116 dmob

dmob

    Polymath

  • Active Members
  • PipPipPipPip
  • 237 posts

Posted 18 August 2009 - 06:52 AM

To download this attachments you have to click on right button of your mouse and choosing "Saving target on"
Renaming FF3.txt in FF3.chm and after all was good


did that and renamed. help file opens, but no content. see attachment.

Edited by dmob, 18 August 2009 - 11:19 AM.


#117 LOULOU

LOULOU

    loulou

  • Active Members
  • PipPipPipPipPipPip
  • 484 posts

Posted 18 August 2009 - 07:18 AM

did that and renamed. help file opens, but no content. see attachment.

Dmob,
Can you delete all the reply of my first post,
I write all the procedure in my first posts.
Thanks

#118 dmob

dmob

    Polymath

  • Active Members
  • PipPipPipPip
  • 237 posts

Posted 18 August 2009 - 11:21 AM

Ah, works fine now. Excellent work...

Thank you

#119 Rishodi

Rishodi

    Seeker

  • Active Members
  • 13 posts

Posted 18 August 2009 - 02:42 PM

I'm not sure what you searching for. What you wanna do with this positions?
Or is there anything you looking for:
https://developer.mozilla.org/en/DOM/window

Aren't window.screenX/Y and window.screenLeft/Right the same?
http://www.javascriptkit.com/domref/windowproperties.shtml

I can't find what I'm looking for in the Gecko DOM Reference, so I wanted to check with someone more familiar before assuming it wasn't there. I'm using these coordinates to have AutoIt make a couple of clicks through a Java application in the browser.

screenX/Y and screenLeft/Top are unfortunately not the same. The former is for Gecko-based browsers and is the offset from the top left corner of the user's screen to the top left corner of the browser window. For example, if your browser is located at (40, 40) on the screen, then screenX/Y will give you (40, 40). The latter is IE-only and gives you the offset from the user's screen to a content window in the DOM. For example, if your browser is located at (40, 40) and you're trying to get the offset of the top-level window, screenLeft/Top will return something like (44, 190), which tells you that the left side of your browser skin is 4 pixels wide and your browser's titlebar and toolbars are 150 pixels high. As far as I can tell, Firefox will give you the size of the browser window as well as the size of any content window in the DOM, but there's no simple way to get the position of any content window relative to the browser window or to the screen.

Edited by Rishodi, 18 August 2009 - 02:43 PM.


#120 Stilgar

Stilgar

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 423 posts

Posted 18 August 2009 - 05:21 PM

Workaround to find the position of the content area:

$a = ControlGetPos(_FFCmd(".title"), "", "[CLASS:MozillaContentWindowClass]") _ArrayDisplay($a)


https://wiki.mozilla.org/Accessibility/AT-Windows-API#How_to_Find_the_Content_Window_and_Load_the_Document

Edited by Stilgar, 18 August 2009 - 05:23 PM.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users