Stilgar Posted August 10, 2009 Author Share Posted August 10, 2009 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) jEdit4AutoIt PlanMaker_UDF Link to comment Share on other sites More sharing options...
GerardJ Posted August 10, 2009 Share Posted August 10, 2009 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 <script type="text/javascript"> function test(){ alert("SIMPLE TEST"); } </script> 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? Link to comment Share on other sites More sharing options...
Stilgar Posted August 10, 2009 Author Share Posted August 10, 2009 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 <script type="text/javascript"> function test(){ alert("SIMPLE TEST"); } </script> 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 jEdit4AutoIt PlanMaker_UDF Link to comment Share on other sites More sharing options...
Rishodi Posted August 10, 2009 Share Posted August 10, 2009 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? Link to comment Share on other sites More sharing options...
GerardJ Posted August 11, 2009 Share Posted August 11, 2009 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/wrappedJSObjectThank 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) Link to comment Share on other sites More sharing options...
Stilgar Posted August 11, 2009 Author Share Posted August 11, 2009 (edited) @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.innerHTMLYou can see there:__FFSend: try{window.content.frames["top"].document.getElementsByClassName('isc-login-swoosh')[0]?1:0;}catch(e){'_FFCmd_Err';}; __FFRecv: 1that 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 August 11, 2009 by Stilgar jEdit4AutoIt PlanMaker_UDF Link to comment Share on other sites More sharing options...
GerardJ Posted August 11, 2009 Share Posted August 11, 2009 @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. Link to comment Share on other sites More sharing options...
Rishodi Posted August 11, 2009 Share Posted August 11, 2009 @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.innerHTMLAh-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! Link to comment Share on other sites More sharing options...
ValeryVal Posted August 13, 2009 Share Posted August 13, 2009 @Stilgar:Thank you for your FF.au3Now AFireFox_Full can manage to SQLite3 DBs by "SQLite Manager Add on" for Firefox.See photo of doing this on AutoItGroup messageor in body of this message. The point of world view Link to comment Share on other sites More sharing options...
coolwulf Posted August 13, 2009 Share Posted August 13, 2009 How can I use FF.au3 to clear Firefix History/cookies etc? Link to comment Share on other sites More sharing options...
Stilgar Posted August 13, 2009 Author Share Posted August 13, 2009 (edited) 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 August 13, 2009 by Stilgar MikahS 1 jEdit4AutoIt PlanMaker_UDF Link to comment Share on other sites More sharing options...
Rishodi Posted August 17, 2009 Share Posted August 17, 2009 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. Link to comment Share on other sites More sharing options...
Stilgar Posted August 17, 2009 Author Share Posted August 17, 2009 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/windowAren't window.screenX/Y and window.screenLeft/Right the same?http://www.javascriptkit.com/domref/windowproperties.shtml jEdit4AutoIt PlanMaker_UDF Link to comment Share on other sites More sharing options...
LOULOU Posted August 18, 2009 Share Posted August 18, 2009 (edited) Hi all,Here is an helpFile FF3.chm for Firefox automation which is an adaptation of Stilgar's helpfile on his webFor safety reason you have to rename FF3.txt to FF3.chmThe forum doesn't allow transmitting a CHM FileBest 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 August 18, 2009 by LOULOU Link to comment Share on other sites More sharing options...
dmob Posted August 18, 2009 Share Posted August 18, 2009 Hi all,Here is an helpFile FF3.chm for Firefox automation which is an adaptation of Stilgar's helpfile on his webFor safety reason you have to rename FF3.txt to FF3.chmThe forum doesn't allow transmitting a CHM FileBest RegardsYour attachment just opens up some garbage:ITSF`ıé¢ý|ª{О É"æìý|ª{О É"æì`xT@Ì@þÌITSPTÿÿÿÿ j’].!Ðù É"æìTÿÿÿÿÿÿÿÿÿÿÿÿPMGL^ÿÿÿÿ//#IDXHDRÒÇ` /#ITBITS /#STRINGSÓ‡Z//#SYSTEMƒ~¡8/#TOPICSÒç`‰@/#URLSTRÒø0*/#URLTBLÒñ ‡ /#WINDOWSÒ°qL/$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ñ Link to comment Share on other sites More sharing options...
dmob Posted August 18, 2009 Share Posted August 18, 2009 (edited) 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 gooddid that and renamed. help file opens, but no content. see attachment. Edited August 18, 2009 by dmob Link to comment Share on other sites More sharing options...
LOULOU Posted August 18, 2009 Share Posted August 18, 2009 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 Link to comment Share on other sites More sharing options...
dmob Posted August 18, 2009 Share Posted August 18, 2009 Ah, works fine now. Excellent work... Thank you Link to comment Share on other sites More sharing options...
Rishodi Posted August 18, 2009 Share Posted August 18, 2009 (edited) 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/windowAren't window.screenX/Y and window.screenLeft/Right the same?http://www.javascriptkit.com/domref/windowproperties.shtmlI 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 August 18, 2009 by Rishodi Link to comment Share on other sites More sharing options...
Stilgar Posted August 18, 2009 Author Share Posted August 18, 2009 (edited) 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 August 18, 2009 by Stilgar jEdit4AutoIt PlanMaker_UDF Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now