Jump to content

Automate firefox


Bert
 Share

Recommended Posts

Hi Stilgar, thank you very much for this wonderful automation library. I've read your example to write inner HTML directly to the body. Can you give an example of how to write scratch HTML and thus release previous content of a page using FF.au3? I mean

[html][...][/...][/html]
etc..
Thank you!

I must try this. document.write fails of security exceptions and there's no innerHTML for "html", but you can try the innerHTMl of content.document.documentElement.

For the other write to the innerHTML of the body, I've made a new function in the current test-version:

Test version

_FFWriteHTML

there's some other new functions, too:

- New: _FFWindowClose(ByRef $Socket[, $sSearch = "Mozilla Firefox"[, $sSearchMode = "title"]])

- New: _FFWindowCloseCurrent(ByRef $Socket)

- New: _FFWindowSelect(ByRef $Socket[, $sSearch = "MozillaFirefox"[, $sSearchMode = "title"]])

- New: _FFWindowSelectMostRecent(ByRef $Socket)

- New: _FFWindowOpen(ByRef $Socket[, $sURL = "about:blank"])

- New: _FFWriteHTML(ByRef $Socket[, $sHTML = ""])

- New: _FFClickXY(ByRef $Socket[, $iX = 0[, $iY = 0[, $bLoadWait = true]]])

Link to comment
Share on other sites

  • Replies 251
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Stilgar:

I must say a big "THANK YOU" for your fantastic UDF for firefox. My German classes in high school are coming in handy!

I have read the instructions but can't seem to find how to do what I would like to do. I want to automatically set the zoom to a specific size (the zoom function is what happens when you press ctrl and + and Ctrl and -) I think this can be done by using setget, but I don't know enough of javascript DOM stuff to make it happen.

Thanks!

Dave

Edited by Kikkymonk
Link to comment
Share on other sites

@Kikkymonk:

Thank you!

You can do this in a single line, too:

#include <FF.au3>

Dim $ff = _FFConnect()

_FFSetGet($ff, 'gBrowser.selectedBrowser.markupDocumentViewer.fullZoom=1.5;')

_FFDisConnect($ff)

then you avoid this temp-var, which is created in the context from the current window.

Edited by Stilgar
Link to comment
Share on other sites

: (

I thought I did everything just like you did but mine didn't work.

I did use start instead of connect. Would that not work?

BUT, thanks a ton for both your UDF and your tech support!!

Well, at least I'm starting to get the DOM stuff.

Thanks!

Dave

Edited by Kikkymonk
Link to comment
Share on other sites

Heh, managed to get this to write full html.

#include <FF.au3>

Dim $ff = _FFConnect()
If $ff = -1 Then Exit

Dim $sHTML = 'java script: content.document.open();content.document.writeln(\"<HTML><HEAD><TITLE>Something</TITLE>' & _
                '</HEAD><BODY><B>Something</B></BODY></HTML>\");content.document.close();'

_FFSetGet($ff, 'content.document.location.href="' & $sHTML & '";')
                
_FFDisConnect($ff)

But it involves "navigating" and content.document.open(); keep throwing exceptions ':P'

Link to comment
Share on other sites

@Authenticity:

I can't get this to work without errors.

document.open() doesn't work because of security reasons:

MDC - document.open

You can try the new version of _FFWriteHTML:

_FFWriteHTML($Socket, $sHTML, "html")

Hi !

On the older version, After I entered frame by _FFrameEnter, I can use _FFOpenURL to open another URL in the frame.

But on this version when I use _FFOpenURL it open URL in the tab (not the frame).

How can I do it like older version ?

Oh this is an error. You can fix it if you replace in _FFOpenURL:

StringFormat('try{content.document.location....

with

StringFormat('try{window.content.document.location....

I'll upload a fixed version today.

Edited by Stilgar
Link to comment
Share on other sites

Hi, Can we run the function even don't need to load the page ? All we do will be through the page source, don't need to load it.

If you mean the _FF_FireFM.au3, you don't have to load any page. This UDF controls the FireFox AddOn "Fire.fm".

This is an example how to control FF-AddOns via the FF.au3.

More AddOn-UDFs are here.

Link to comment
Share on other sites

If you mean the _FF_FireFM.au3, you don't have to load any page. This UDF controls the FireFox AddOn "Fire.fm".

This is an example how to control FF-AddOns via the FF.au3.

More AddOn-UDFs are here.

I didn't mean that. I mean that we only need the page source, then base on the page source we access to the final page we want to surf.

For e.g

I want search "autoIT" from Google page, I don't need to load competely Google.com, it will waste time.

I need the Google page source then base on it I will find out "www.autoitscript.com" because this link will in Google page source.

Sorry for my English :P

Link to comment
Share on other sites

I think you mean the function from this post.

From which function do you are talking about?

For my above e.g, there may be _FFopenURL and _FFclicklink

But can you write every function be possible work on the source page ?

Can you add a get source function form FF like _INetgetsource then every function will work on the source.

Just a little idea :P

Link to comment
Share on other sites

For my above e.g, there may be _FFopenURL and _FFclicklink

But can you write every function be possible work on the source page ?

Can you add a get source function form FF like _INetgetsource then every function will work on the source.

Just a little idea :P

This can only work with pure HTML pages. It fails if there is Javascript or with Javascript generated content.

E.g _FFClickLink not only opens an URL it fires a click-event on the link.

And how would you fill and submit a form with the html-source?

Things like _FFXPath can't work without the browser.

How should it work with things like AJAX?

...

short answer: no

[EDIT]

And why should I do this? The FF.au3 is an UDF to automate FireFox :unsure: - that's all.

[EDIT2]

Added a "zoom" action to _FFAction in the last version:

_FFSetGet($ff, 'gBrowser.selectedBrowser.markupDocumentViewer.fullZoom=1.5;')

=>

_FFAction($ff,"zoom",1.5)

Edited by Stilgar
Link to comment
Share on other sites

Yes, but it will improve FF.au3 speed. Even I see the _FFsearch func is search through the source so sometimes it returns true but the string hasn't appeared on the page yet. That sometimes is good but sometimes is bad :P

Here is a error in _FFsearch func

Details:

name: NS_ERROR_INVALID_POINTER

result: 2147500035

QueryInterface:

function QueryInterface() {

[native code]

}

message: Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMJSwindow.find]

filename: chrome://mozrepl/content/repl.js -> file:///C:/Documents%20and%20Settings/trinitro%20toluen/Application%20Data/Mozilla/Firefox/Profiles/t5kkg8jz.TNT/mozrepl.tmp.js

lineNumber: 1

columnNumber: 0

location: JS frame :: chrome://mozrepl/content/repl.js -> file:///C:/Documents%20and%20Settings/trinitro%20toluen/Application%20Data/Mozilla/Firefox/Profiles/t5kkg8jz.TNT/mozrepl.tmp.js :: <TOP_LEVEL> :: line 1

inner: null

data: null

initialize:

function initialize() {

[native code]

}

__FFSend: content.find("Waiting ...", false, false, true, false, true, false)

__FFRecv: !!! [Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMJSwindow.find]" nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)" location: "JS frame :: chrome://mozrepl/content/repl.js -> file:///C:/Documents%20and%20Settings/trinitro%20toluen/Application%20Data/Mozilla/Firefox/Profiles/t5kkg8jz.TNT/mozrepl.tmp.js :: <TOP_LEVEL> :: line 1" data: no]

Details:

name: NS_ERROR_INVALID_POINTER

result: 2147500035

QueryInterface:

function QueryInterface() {

[native code]

}

message: Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMJSwindow.find]

filename: chrome://mozrepl/content/repl.js -> file:///C:/Documents%20and%20Settings/trinitro%20toluen/Application%20Data/Mozilla/Firefox/Profiles/t5kkg8jz.TNT/mozrepl.tmp.js

lineNumber: 1

columnNumber: 0

location: JS frame :: chrome://mozrepl/content/repl.js -> file:///C:/Documents%20and%20Settings/trinitro%20toluen/Application%20Data/Mozilla/Firefox/Profiles/t5kkg8jz.TNT/mozrepl.tmp.js :: <TOP_LEVEL> :: line 1

inner: null

data: null

initialize:

function initialize() {

[native code]

}

__FFSend: content.find("Waiting ...", false, false, true, false, true, false)

__FFRecv: !!! [Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMJSwindow.find]" nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)" location: "JS frame :: chrome://mozrepl/content/repl.js -> file:///C:/Documents%20and%20Settings/trinitro%20toluen/Application%20Data/Mozilla/Firefox/Profiles/t5kkg8jz.TNT/mozrepl.tmp.js :: <TOP_LEVEL> :: line 1" data: no]

Edited by trinitrotoluen
Link to comment
Share on other sites

...

I can't get this to work without errors.

document.open() doesn't work because of security reasons:

....

Indeed, it throws exceptions and you get error returning from _FFSetGet but it does work for, I believe, no bigger than 8K byte navigating string.

If you can confirm it works for you, even with exceptions and error, it will be nice. ;]

Link to comment
Share on other sites

@Authenticity:

Sorry it doesn't work here. The only way is to overwrite the innerHTML from documentContent.

@trinitrotoluen:

It wouldn't improve the speed, if you must made all the cookie-handling, Javascript-Interpreter ... with AutoIt.

But you can try it :P

But the speed limit from the FF.au3 is not FireFox, it's the telnet connection to MozRepl. Every command I have to send and receive takes min. 20ms.

Is that error in _FFSearch reproducible? Same error on the same page? Or is this different?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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