Jump to content
Sign in to follow this  
Bert

Automate firefox

Recommended Posts

Thanks Stilgar.

I tried:

$Socket = _FFStart ("about:blank")

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

But there is an error says "Reference error: FF_AutoItScript is not defined".

Could you please correct me?

Thanks!

Share this post


Link to post
Share on other sites

If the functions are working this "error" is no problem.

On the first connection from FF.au3 to FF the FF.au3 checks if there is the object " FF_AutoItScript", if not it is created by the FF.au3.

You can see this in one of the next lines in the console:

"__FFSend: FF_AutoItScript = new Object(); ...."

Share this post


Link to post
Share on other sites

You could also use:

_FFSetGet($Socket, 'content.document.location.href="' & $sIP & '"')

like _FFOPenURL does :)


*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

Hey all,

This is really amazing. :) I have a few questions regarding MozLab:

1) does it not support the latest version of FF yet (3.02/3.03)? Any known workaround or so?

2) I don't understand what the plugin does but apparently it allows remote access? How secure or insecure is that to use it on a business PC? Or can it be restricted to only work with local/internal or localhost IPs?

3) No chance for Autoit + ff3.au3 to work with FF without using the Mozlab plugin? Maybe someone can give me an easy, short description how these things interact with each other and why it has to be done this way? >_<

Share this post


Link to post
Share on other sites

1) It works with from FF V2.x up to the latest version of FF V3.0.3 and MozLab V0.2b1.2008081713

2) You can disable outside connections in the MozLab-Menu so it works only on localhost

3) Sorry, no chance. The GUI from FF is only XUL and Javascript so you can't interact with it, with normal Windows-tools. MozLab (MozRepl) gives you a telnet port to FF and via this connection the FF.au3 interact with FF.

Share this post


Link to post
Share on other sites

I'm using FF.au3 (and AutoIt) for the first time, and need some help here, please.

I'm using AutoIt v3.2.12.1, FF.au3 v0.2.4.0beta, SciTE v1.76, MozRepl 2008 10 12 19 and FireFox 3.0.3, on WinXP Pro Sp3.

So far I've got this:

#include <FF.au3>
$Socket = _FFStart("http://privilege.ftlatest.com","default",2)
_FFSetValueByName($Socket, "ucpnlHeader:LoginHeader_ctl1:txtCPN", "12345")
_FFSetValueByName($Socket, "ucpnlHeader:LoginHeader_ctl1:txtPostCode", "aa9 5bb")
_FFClickImage($Socket,"ucpnlHeader:LoginHeader_ctl1:btnSubmit","name")

The last few lines of the SciTE log look like this:

__FFSend: content.wrappedJSObject.frames["top"].document.getElementsByName("ucpnlHeader:LoginHeader_ctl1:txtCPN")[0].value="12345"

__FFRecv: 12345

__FFSend: content.wrappedJSObject.frames["top"].document.getElementsByName("ucpnlHeader:LoginHeader_ctl1:txtPostCode")[0].value="aa9 5bb"

__FFRecv: aa9 5bb

__FFSend: FF_AutoItScript.SearchImageLink(/name[ \t]*=[ \t]*(.*)ucpnlHeader:LoginHeader_ctl1:btnSubmit/,"top")

__FFRecv: -1

_FFClickImage ==> No match: ucpnlHeader:LoginHeader_ctl1:btnSubmit

+>13:05:47 AutoIT3.exe ended.rc:0

I tried using the FF Page Analyzer, but couldn't find the login button on my web page. I therefore looked directly at the page source from the page http://privilege.ftlatest.com/home.aspx?id_content=1, and found this line:

<input type="image" name="ucpnlHeader:LoginHeader_ctl1:btnSubmit" onclick="if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); "   id="ucpnlHeader_LoginHeader_ctl1_btnSubmit" class="btn" src="/images/btn-login.gif" alt="" border="0" /><BR>

so I used the value of the name property in my _FFClickImage statement.

The two _FFSetValueByName lines appear to be working perfectly, but what is wrong with the _FFClickImage statement?

Edited by KenTurner

Share this post


Link to post
Share on other sites

cross-domain security issue ... I am having the same problem.

Ok, I see that you added the frame support, but there is no documentation and I cannot seem to get it to work.

I decided to use it on one of my old myspace bots, and I tried to change it from using my old method of having the window sized exactly and hidden, and using the control commands.

I can get into the app perfectly, easier then the hours it first took me, but when I get to the app window, and it pulls up the app's frame, I cant get into it. I am simply searching for a term inside it the frame "REFRESH" in this case, and trying every single frame ID possible.

Something like this:

MsgBox(0,_FFFrameSelected($Socket),_FFAction($Socket,"search","REFRESH"))
    _FFFrameEnter($Socket, 1)
    _FFClickLink($Socket, "REFRESH", "text")
    _FFClick($Socket, "Missions", "text")
    MsgBox(0,_FFFrameSelected($Socket),_FFAction($Socket,"search","REFRESH"))
    _FFFrameEnter($Socket,2)
    _FFClickLink($Socket, "REFRESH", "text")
    _FFClick($Socket, "Missions", "text")
    MsgBox(0,_FFFrameSelected($Socket),_FFAction($Socket,"search","REFRESH"))
    _FFFrameEnter($Socket,3)
    _FFClickLink($Socket, "REFRESH", "text")
    _FFClick($Socket, "Missions", "text")
    MsgBox(0,_FFFrameSelected($Socket),_FFAction($Socket,"search","REFRESH"))
    _FFFrameEnter($Socket,4)
    _FFClickLink($Socket, "REFRESH", "text")
    _FFClick($Socket, "Missions", "text")
    MsgBox(0,_FFFrameSelected($Socket),_FFAction($Socket,"search","REFRESH"))
    _FFFrameEnter($Socket,5)
    _FFClickLink($Socket, "REFRESH", "text")
    _FFClick($Socket, "Missions", "text")
    MsgBox(0,_FFFrameSelected($Socket),_FFAction($Socket,"search","REFRESH"))

But the clicks do not happen and the search always returns false.

Any ideas?

Share this post


Link to post
Share on other sites

@stilgar

Awesome work !

Im happy to see that someone have took time to work on me :)

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

@KenTurner:

Sorry for the late answer ...

I don't know why, but you can see the <input type="image" in the Dome from FF.

So the only thing you can try is to submit the form with _FFFormSubmit or with _FFClick.

@FireFox:

Thank you!

@trinitrotoluen:

If you mean the whole text of the page:

$sText = _FFReadText($Socket)

Share this post


Link to post
Share on other sites

Ok, I found that : $Get = _FFSetGet ($Socket, 'content.window.getSelection().toString()') :)

p/s : Where I can learn the FF java scripts like the script above.

Oh no ! It don't work it with Frames in Firefox and the copy func _FFSetGet ($Socket, 'content.window.getSelection()') don't work with frames, either.

Share this post


Link to post
Share on other sites

you could write a function :)

if selection is empty, nothing or whatever, loop

window.frames[]

and use

window.frames[index].getSelection(); :o

possibly this way:

$sJavascript = 'FF_AutoItScript.getSelection = function getSelection()'
    $sJavascript &= '{ var selection;'
    $sJavascript &= 'selection = content.window.getSelection();'
    $sJavascript &= 'if (selection == nothing) { '
    $sJavascript &= 'for (i=0;i<content.window.frames.length;i++)'
    $sJavascript &= '{'
    $sJavascript &= '   selection = content.window.frames[i].getSelection();'
    $sJavascript &= '   if (! (selection == nothing) ) return selection.toString();'
    $sJavascript &= '} else{ '
    $sJavascript &= '  return selection.toString(); '
    $sJavascript &= '} return ""; '
    $sJavascript &= '}};'

    _FFSetGet($Socket, $sJavascript,1000)

$sel= _FFSetGet($Socket, "FF_AutoItScript.getSelection();",1000)

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

Or the same in AutoIt

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

$Socket = _FFStart("http://thorsten-willert.de",default,2)

If $Socket <> -1 Then
    For $i = 0 To _FFGetLength($Socket,"frames")
        _FFFrameEnter($Socket,$i)
        If Not @error Then
            If _FFAction($Socket,"search","Neues") Then
                $sText = _FFSetGet ($Socket, '.getSelection().toString()')
                If $sText <> "" Then msgbox(64,"", $sText)
            EndIf
        EndIf
    Next
    _FFDisConnect($Socket)
EndIf

@trinitrotoluen:

You can look for the Javascript-code + DOM reference here:

https://developer.mozilla.org/en/Gecko_DOM_Reference

Edited by Stilgar

Share this post


Link to post
Share on other sites

Is it possible to control multi Firefoxs with difference profiles at the same time ? Because I see that the socket when I open difference Firefox's profile is the same (_FFConnect: Socket: 1624) so I wanna ask if it is possible to recognize multi Firefox profile windows at the same time.

Share this post


Link to post
Share on other sites

Yes it's possible. If you change the default port-number and profile from FF with _FFStart you can do this.

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

Or you can control the same FF-window with different programms/connections via different sockets ... but this is an other thing :)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...