Jump to content

Recommended Posts

Posted

This is more clear and easy FF_Browser_Start.au3 script, I think:

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <FF.au3>

Global $WGui    = 640
Global $HGui    = 580
Global $XBr = 10
Global $YBr = 80
Global $WBr = 620
Global $HBr = 490
Global $hWnd

$hWnd = GUICreate ( "Embedded FireFox Test", $WGui, $HGui,(@DesktopWidth-$WGui)/2, (@DesktopHeight-$HGui)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

; Create Buttons
$GUI_To = GuiCtrlCreateButton("To", 10, 10, 50, 25)
$GUI_Back = GuiCtrlCreateButton("Back", 60, 10, 50, 25)
$GUI_Forward = GuiCtrlCreateButton("Forward", 110,10, 50, 25)
$GUI_Home = GuiCtrlCreateButton("Home", 160, 10, 50, 25)
$GUI_Stop = GuiCtrlCreateButton("Stop", 210, 10, 50, 25)
$GUI_Refresh = GuiCtrlCreateButton("Refresh", 260, 10, 50, 25)
$GUI_Print = GuiCtrlCreateButton("Print", 310, 10, 50, 25)

; Create input control
$GUI_Input = GuiCtrlCreateInput("www.google.com", 10, 50, 300, 20)
GUICtrlSetResizing ($GUI_Input, $GUI_DOCKALL)

GUISetState()

_FF_CreateEmbedded($hWnd, $XBr, $YBr, $WBr, $HBr)
_FFOpenURL("Google.com")

While True
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_To
           $URL = GUICtrlRead($GUI_Input)
           _FFOpenURL($URL)
        Case $msg = $GUI_Back
            _FFAction("Back", "")
        Case $msg = $GUI_Forward
            _FFAction("Forward", "")
        Case $msg = $GUI_Home
            _FFAction("Home", "")
        Case $msg = $GUI_Stop
            _FFAction("Stop", "")
        Case $msg = $GUI_Refresh
            _FFAction("Refresh", "")
        Case $msg = $GUI_Print
            _FFAction("Print", "")
    EndSelect
WEnd

_FFQuit()
GUIDelete()
exit


;===============================================================================
Func _FF_CreateEmbedded($hGUI,$x, $y, $w, $h, $iTimeOut = 10000)
    Local $OK

    Local $sHKLM = "HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox"
    Local $sFFExe = RegRead($sHKLM & "\" & RegRead($sHKLM, "CurrentVersion") & "\Main", "PathToExe")

    WinSetOnTop($hGUI,"",1)

    Run($sFFExe & ' new-window -P "default" about:blank', "", @SW_HIDE)
    Local $iTimeOutTimer = TimerInit()
    While 1
        Sleep(500)
        If ProcessExists($_FF_PROC_NAME) Then ExitLoop
        If (TimerDiff($iTimeOutTimer) > $iTimeOut) Then
            MsgBox(0,"Error", "Browser process not exists!")
            Return ""
        EndIf
    WEnd

    Do
        _FFConnect()
        $OK = @error
        If @error Then _FFDisConnect()
    Until Not $OK

    _FFWindowSelect()

    Local $hFF = _FFWindowGetHandle()
    
    WinMove($hFF, "", $x, $y, $w, $h)

    Do
        _FFAction("pm", True)
    Until Not @error

    WinMove($hFF, "", $x, $y, $w, $h)
    DllCall("user32.dll", "int", "SetParent", "hwnd", $hFF, "hwnd", $hGui)
    WinSetOnTop($hGUI,"",0)

    Return $hFF
EndFunc

It uses default profile, doesn't touch existing FireFox, has input for URL and basic buttons.

Much good example! Fine i try make (handle, dllcall, other) to just classname "[CLASS:MozillaWindowClass; INSTANCE:3]" is not work :/ ... problem bar firefox

Help me is thanks!

Programmer PHP, ASP, CGI, Perl, Delphi, JScript, ......... :)

Posted

What should be the syntax _FFClick (to press the button on the FF)?

Page source:

<Input id = "press_button_788857" type = "button" value = "Press!" onclick = "press (788,857); return false;"> <br/> <br/>

The Russian version of _FFClick() is obsolete. There's no mention that this feature will only work after page is fully loaded (in the English version - "Optional: Waits until the page is loading.True = (Default)" and so on.

I see that the page is loaded, and the function does not work, but sometimes works.

I've already written

_FFImageClick ("Vote_button_788857", "id", 0)

_FFClick ("Vote_button_788857", "id", 1)

Then, triggered more often.

But after refreshing the page, this feature does not work at all.

Along the way I encountered the work features _FFStart (),

; _FFConnect () _FFOpenURL (), _FFWindowClose (),

_FFQuit ().

I decided that if the button works on freshly page

do the following - after pressing the button, to close the page and then open it again, but also climbed errors. What is the procedure for the use of these functions, if there is a good example.

By the way, how do instead of clicking "reload" just to get into the address bar, and press enter?

Posted (edited)

Can't. BusyFlags are global. You need to use function AddEventListener, with "DOMContentLoaded" as first argument.

how exactly would I implement those functions into this FF.au3...?

would you mind posting an example code please..?

Edited by cypher175
Posted

Is there some kinda connection limit on MozRepl that limits only 10 max connections to FireFox though the mozrepl plugin..?

I made 20 processes that each interact with different tabs by navigating each tab url to random websites, but only 10 of the processes seem to be able to work at a time..?

Is this a limitation of the mozrepl plugin, or is there a setting somewhere to change this connection limit..??

Posted

Can anyone tell me the code to get the cookies, i tried literally almost everything but i couldnt figure it out

I believe this is the code to get cookies but i dont know how to implement it on autoit

var ios = Components.classes["@mozilla.org/network/io-service;1"]
            .getService(Components.interfaces.nsIIOService);
var uri = ios.newURI("http://www.google.com/", null, null);
var cookieSvc =
   Components.classes["@mozilla.org/cookieService;1"]
             .getService(Components.interfaces.nsICookieService);
var cookie = cookieSvc.getCookieString(uri, null);
Posted

Is there some kinda connection limit on MozRepl that limits only 10 max connections to FireFox though the mozrepl plugin..?

I made 20 processes that each interact with different tabs by navigating each tab url to random websites, but only 10 of the processes seem to be able to work at a time..?

Is this a limitation of the mozrepl plugin, or is there a setting somewhere to change this connection limit..??

Find that part in FF.au3:
; multiple connections to MozRepl (e.g repl2?> ...)
If StringRegExp($recv, "repl[\d]?>") Then Return StringRegExpReplace($sRet, "repl[\d]?>", "")

Then replace it with

If StringRegExp($recv, "repl[\d]*>") Then Return StringRegExpReplace($sRet, "repl[\d]*>", "")

- - -

Can anyone tell me the code to get the cookies, i tried literally almost everything but i couldnt figure it out

I believe this is the code to get cookies but i dont know how to implement it on autoit

Just make a string out of your code you've inserted, then pass that string to _FFCmd

Or better download this:

http://www.google.com/search?q=nc111nt.zip, connect to

localhost 4242

Posted

i have this

func getcookies()
$ios = 'Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);'
$uri = ios.newURI("http://www.google.com/", null, null);
$cookieSvc = 'Components.classes["@mozilla.org/cookieService;1"].getService(Components.interfaces.nsICookieService);'
$cookie = cookieSvc.getCookieString(uri, null);
  _FFCMd($ios)
  _FFCMd($uri)
  _FFCMd($cookieSvc)
Return  _FFCMd($cookie)
EndFunc

and am gettting _ffcmd_error

could you please post a working example.

Posted

Func getffcookies()


 $ios = 'Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService)'
$uri = _FFcmd($ios&'.newURI("http://www.google.com/", null, null);')
msgbox(0,"uri",$uri)
$cookieSvc = 'Components.classes["@mozilla.org/cookieService;1"].getService(Components.interfaces.nsICookieService)'

$cookie = _FFCmd($cookieSvc&'.getCookieString('&$uri&', null);')

Return  $cookie
EndFunc

i ve tried this and $uri i think is returning good. but cookies only returns an empty string i ve been pulling my hair trying to get this right. What is the correct way to get the cookies using this, i know am close and am missing something.

Posted (edited)

$b = _FFCmd('var ios = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);' & _
'var uri = ios.newURI("http://www.google.com/", null, null);' & _
'var cookieSvc=Components.classes["@mozilla.org/cookieService;1"].getService(Components.interfaces.nsICookieService);' & _
'var cookie = cookieSvc.getCookieString(uri, null);' & _
'cookie;')

MsgBox(0, '', $<img src='http://www.autoitscript.com/forum/public/style_emoticons/<#EMO_DIR#>/cool.png' class='bbc_emoticon' alt='B)' />

Which part of "Just make a string out of your code you've inserted, then pass that string to _FFCmd" was unintelligible?

Edited by 4ggr35510n
Posted

wait a minute , you can do that?

lol i honestly didnt think you could do that. I thought you meant put an autoit string.

I forgot about that. I guess i owe you a beer now haha!!!

Posted

My pleasure :graduated:

Sure you can do it! You've found ready javascript for receiving cookie-string. Since MozRepl is a plugin activating* javascript on the fly, you need just to add 'cookie;' a the end of the string, to MozRepl return the 'var cookie' value, that value is caught by _FFCmd function and Returned[/blue].

The most of javascripts you can find in MDC portal 'messing with Firefox itself' can be happily executed just by passing them into _FFCmd as one string.

I'm sorry if I haven't explained clearly enough concept of bypassing string before.

* inserting them into head of document first actually; then activating

Good luck messing with Firefox!

4gr

  • 1 month later...
Posted

Hi there!

I'm getting myself back into working with AutoIt, and I've decided to try my luck at automating a browser game. Some of the features of the game are enhanced by a GreaseMonkey script, which is why I have chosen to automate Firefox. I would first like to say that this is a great library and it has been very helpful thus far :x

I have run into an issue, namely that most of the functions I use always apply to the first tab opened. For example, I would open a second tab to a different page, use _FFClick to try and click on an element on that tab, but it keeps searching the first tab for the element to click. I've had difficulty using multiple windows as well, for the same reason. Is there a way to circumvent this?

Many thanks for your consideration, and my apologies if this has been addressed before or is a trivial issue.

Cheers!

Posted

Oops! Sorry about that, I felt it was necessary to state the context of my work. Does this mean that I won't receive help for my issue because of that?

Also, I feel I left out some info in my explanation. I'm trying to use _FFClick on a value returned by _FFXPath (FIRST_ORDERED_NODE_TYPE) but I think it's only looking in the first tab (which is unselected). On a semi-related note, If I try using _FFLinksGetAll, it only returns the links listed in the first tab (which again is unselected).

Posted

Oops! Sorry about that, I felt it was necessary to state the context of my work. Does this mean that I won't receive help for my issue because of that?

Also, I feel I left out some info in my explanation. I'm trying to use _FFClick on a value returned by _FFXPath (FIRST_ORDERED_NODE_TYPE) but I think it's only looking in the first tab (which is unselected). On a semi-related note, If I try using _FFLinksGetAll, it only returns the links listed in the first tab (which again is unselected).

Apologies for the double post, but I have found a workaround for this issue, in case anyone had the same problem. I noticed that I could access elements in the second tab if I used _FFOpenURL while that tab was active before I did anything else. Looking at the source for _FFOpenURL, I noticed this line of code:

_FFCmd("FFau3.WCD=window.content.top.document;")

Adding this directly after the _FFTabSetSelected function worked like a charm! If I could make a recommendation, it would be great if this could be added into the _FFTabSetSelected/_FFTabAdd/Window functions in future updates. Thanks :x

Cheers!

  • 2 weeks later...
Posted

Apologies for the double post

You mean triple post.

gBrowser.mTabs
object contains all opened Tabs in one instant of browser.

With

gBrowser.mTabs.length

You can get the length of this object ERGO the number of opened tabs.

With

gBrowser.mTabs[gBrowser.mTabs.length-1].linkedBrowser.contentwindow.document.location.href

You can get the http://* location of the last opened tab.

Just an example, I hope it's understandable, that codes below you need to use as an argument in _FFCmd() function. And return values of those code samples (length in first and location in second) will be the return values of _FFCmd() function.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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