Jump to content

Automate firefox


Bert
 Share

Recommended Posts

There is a liitle mistake on function _FFOpenURL :

1. I can only type _FFOpenURL($Socket,"http://google.com") but i can't type _FFOpenURL($Socket,"google.com"), if the func don't contain http:// the code won't work.

2. I can't use it to access my router web address. Ex : _FFOpenURL($Socket,"http://192.168.1.1/")

ps : Is there any func work with Firefox Dialog box ? Like the dialog box ask for username and password every time I access to my router website ?

edit : How can I connect through proxy ? thanks

Regard ! trinitrotoluen !

Edited by trinitrotoluen
Link to comment
Share on other sites

  • Replies 251
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

There's no mistake in the _FFOpenURL-function, that's a check if the URL is a correct http/https/ftp-adress.

If you want to open an IP you can use:

_FFSetGet($Socket ,".location.href='http://192.168.1.1'")

What do you mean with dialog-box? A HTML-form? If yes, you can create with this tool:

http://thorsten-willert.de/Themen/AutoIt-F...lyzer/index.php

login-scripts.

Connecting through a proxy depends on your FF prefs.

Link to comment
Share on other sites

There's no mistake in the _FFOpenURL-function, that's a check if the URL is a correct http/https/ftp-adress.

If you want to open an IP you can use:

_FFSetGet($Socket ,".location.href='http://192.168.1.1'")

What do you mean with dialog-box? A HTML-form? If yes, you can create with this tool:

http://thorsten-willert.de/Themen/AutoIt-F...lyzer/index.php

login-scripts.

Connecting through a proxy depends on your FF prefs.

Thank you for your guide.

I wanna ask if i can clear cookies and change my proxy then continue surf web.

Link to comment
Share on other sites

You can remove all cookies with:

_FFSetGet($Socket,'Components.classes["@mozilla.org/cookiemanager;1"].getService(Components.interfaces.nsICookieManager).removeAll();')oÝ÷ Úm¦+µ«­¢+Ù}MÑÐ ÀÌØíM½­Ð°Ìäí
½µÁ½¹¹Ñ̹±ÍÍÍlÅÕ½Ðíµ½é¥±±¹½É½ÁÉɹ̵ÍÉÙ¥ìÄÅÕ½Ðít¹ÑMÉÙ¥¡
½µÁ½¹¹Ñ̹¥¹ÑÉ̹¹Í%AÉ  ɹ ¤¹ÍÑ%¹ÑAÉ ÅÕ½Ðí¹Ñݽɬ¹Áɽá乡ÑÑÁ}Á½ÉÐÅÕ½Ðì°àÀàÀ¤ìÌäì¤
Link to comment
Share on other sites

How can I remove Frame or Stop loading frame ?

Ps : _FFStart ([$ SURL = "about: blank" [, $ sProfile = "default" [, $ iMode = 1 [, $ bHide = False [, $ IP = "127.0.0.1" [, $ iPort = 4242]]] ]]])

If I set Hide = True, Is it the Firefox process will not be recognized in Task Manager ?

Edited by trinitrotoluen
Link to comment
Share on other sites

The Func _FFaction($socket,"reload") with flag seem to be not work

http://developer.mozilla.org/en/docs/XUL:M...reloadWithFlags

Flags:

* LOAD_FLAGS_NONE: No special flags. The document is loaded normally.

* LOAD_FLAGS_BYPASS_CACHE: Reload the page, ignoring if it is already in the cache. This is the flag used when the reload button is pressed while the Shift key is held down.

* LOAD_FLAGS_BYPASS_PROXY: Reload the page, ignoring the proxy server.

* LOAD_FLAGS_CHARSET_CHANGE: This flag is used if the document needs to be reloaded because the character set changed.

You may combine flags using a or symbol ( | ).

I have tried and can't see any different between them
Link to comment
Share on other sites

@trinitrotoluen:

- _FFaction($socket,"reload"): How did you tried it? Here it works.

- _FFStart $bHide = True: FireFox starts with a hidden window, but the task is visible in the Task Manager (currently this function is not working, I'll fix this in the next version)

- How can I remove Frame or Stop loading frame:

Do you wanna stop loading a single frame or the complete frameset? And what do you mean with removing a frame?

Link to comment
Share on other sites

@dmob:

You can monitoring the downloads for example with this:

FF downloads

What would you regulate?

@stilgar

Thanks for the link, but from what I could gather (Google translation screws up the code) that reads the status.

What I would like to do is control the downloads by stopping, pausing and resuming the download(s).

I operate a small internet cafe, and I want to be able to:

1 - detect a download

2 - pause the download

3 - calculate cost of download

4 - inform the customer of the cost of the download and ask for confirmation

5 - resume or cancel the download as per customer confirmation

I have managed to get all done except for 2 and 5.

I used the downloads database (SQLite) from the FF profiles folder. I noticed that there is a State field

which indicates the current status of the d/load. I tried setting the values in there. The status on the downloads

window changes, but the download is not paused, stopped or cancel, so that didn't work.

I would highly appreciate any help in this regard, as it's causing friction with my customers.

Edited by dmob
Link to comment
Share on other sites

@dmob:

I see.

To do this you can use all the functions from the "Download-Window", you can find them in the

"*Mozilla Firefox\chrome\toolkit.jar" ->

/content/mozapps/downloads/downloads.js

You can use them in a tab with:

chrome://mozapps/content/downloads/downloads.xul

by using them via performCommand(aCmd, aItem) (that's a function in downloads.js)

But I think a better way to manage all this things is to modify a FireFox-Addon like the Download Manager Tweak

Link to comment
Share on other sites

@dmob:

I see.

To do this you can use all the functions from the "Download-Window", you can find them in the

"*Mozilla Firefox\chrome\toolkit.jar" ->

/content/mozapps/downloads/downloads.js

You can use them in a tab with:

chrome://mozapps/content/downloads/downloads.xul

by using them via performCommand(aCmd, aItem) (that's a function in downloads.js)

I opened the files in the toolkit and found this:

CODE
<vbox id="contextMenuPalette" hidden="true">

<menuitem id="menuitem_pause"

label="&cmd.pause.label;" accesskey="&cmd.pause.accesskey;"

oncommand="performCommand('cmd_pause');"

cmd="cmd_pause"/>

<menuitem id="menuitem_resume"

label="&cmd.resume.label;" accesskey="&cmd.resume.accesskey;"

oncommand="performCommand('cmd_resume');"

cmd="cmd_resume"/>

<menuitem id="menuitem_cancel"

label="&cmd.cancel.label;" accesskey="&cmd.cancel.accesskey;"

oncommand="performCommand('cmd_cancel');"

cmd="cmd_cancel"/>

This looks like what I want to do, problem is, I don't know how to use them or call them from within AutoIt.

But I think a better way to manage all this things is to modify a FireFox-Addon like the Download Manager Tweak

That add-on is for an older version of FF, and I have no idea how to tweak add-ons, nor where to look or start.

If you could please give me a push in the right direction, I would appreciate any help.

Link to comment
Share on other sites

@dmob:

Here is a short example to control the download-manager.

To try this script, you must download a file and pause the download. If you run it, it shows you the number of downloads, the size of the first download and resumes the first download.

For the resume I've used the resumeDownload()-function from the downloads.js.

#region Includes
#include <FF.au3>
#endregion Includes

$Socket = _FFConnect()

If $Socket > -1 Then
    _FFOpenURL($Socket,"chrome://mozapps/content/downloads/downloads.xul")

    ; number of downloads
    $iDownloads = _FFSetGet($Socket,'var FF_dV = content.document.getElementById("downloadView");FF_dV.itemCount;')
    MsgBox(64,"Number of Downloads",$iDownloads)

    If $iDownloads > 0 Then
        ; Download ID, first download
        $iDownloadID = _FFSetGet($Socket,'FF_dV.getItemAtIndex(0).getAttribute("dlid");')
        MsgBox(64,"Download-ID, first download",$iDownloadID)

        ; maxBytes, first download
        $iDownloadBytes = _FFSetGet($Socket,'FF_dV.getItemAtIndex(0).getAttribute("maxBytes");')
        MsgBox(64,"maxBytes / size, first download",$iDownloadBytes)

        ; restarting first download
        ; https://developer.mozilla.org/en/NsIDownloadManager
        _FFSetGet($Socket,'Components.classes["@mozilla.org/download-manager;1"].getService(Components.interfaces.nsIDownloadManager).resumeDownload(' & $iDownloadID &');')
    EndIf
EndIf
Edited by Stilgar
Link to comment
Share on other sites

@fspafford:

At first you must "enter" the frame with your button:

_FFFrameEnter()

is this a button to submit a form or an other one?

Or you can generate a command with this program:

http://thorsten-willert.de/Themen/AutoIt-F...lyzer/index.php

The button does not submit a form - it causes another page to be opened. Currently, I use _FFOpenURL() to simulate the button click.

Unfortunately, the page analyzer does not work on this page - I get the error "can't open connection to Firefox". (It does work on other pages.)

Frank

Link to comment
Share on other sites

Ahh, thank you @stilgar, you are the man!

I will certainly get busy with that (although I don't want to have to open the downloads

window, since it might distract/confuse the customers).

The code and link you provided will get me where I want. :)

Thank you for your time and skill!

Link to comment
Share on other sites

You can click the button (or any other element with an ID) with this:

_FFClick($Socket,".getElementById('ID')")

What page is it? So I can try to find out why the page analyzer doesn't work there.

Thank you, that worked.

The page is from a network switch, which is not publicly accessible.

Frank

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...