Jump to content

Embedded firefox with mozrepl


Recommended Posts

Hi guys!
I found some solution for embedded firefox so i tested it:
 

#include <GUIConstants.au3>

$oFF = ObjCreate("Mozilla.Browser")
if Not Isobj($oFF) then
Msgbox(0,"Mozilla","Can't get Mozilla")
endif

GUICreate ( "FF Embedded Web control Test", 1200, 800, Default, Default, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj ( $oFF, 0, 0 , 1200 , 800 )
GUISetState () ;Show GUI
$oFF.navigate("https://www.google.com/")
MsgBox(0,"","")

It works fine but only if I tried run google.com. Other pages were blank.
And there is some popup all the time.
Another thing is how can i get html of curret page or click on element by id like in FF.au3
 

Link to comment
Share on other sites

It doesn't work:71_VollBild.thumb.jpg.1488ae0fd17fba409b

I suggest: try to get the handle of FireFox window $hWin = _FFWindowGetHandle()  and make it to a child of your GUI. This short example:

#include<GUIConstantsEx.au3>
#include<WinAPI.au3>
#include<WindowsConstants.au3>
#include<Constants.au3>
$hGUIMain = GUICreate("Parent")


$Toolbar_hoehe = 30
$Toolbar_breite= 100

$hGUITool = GUICreate("Toolbar", $Toolbar_breite ,$Toolbar_hoehe,-1,-1,$WS_SYSMENU+$WS_CAPTION,$WS_EX_TOOLWINDOW)
$Toolbarfenster = WinGetPos($hGUITool)
GUISetBkColor(0xaabbcc)
$btnToggle = GUICtrlCreateButton("TG",1,1,28,28)
GUISetState(@SW_SHOW,$hGUIMain)
GUISetState(@SW_SHOW,$hGUITool)

While 1
    $avMsg = GUIGetMsg(1)
    Switch $avMsg[1]
        Case $hGUIMain
            Switch $avMsg[0]
                Case -3
                    Exit
            EndSwitch
        Case $hGUITool
            Switch $avMsg[0]
                Case $btnToggle
                    If _WinAPI_GetParent($hGUITool) <> $hGUIMain Then ContinueCase ; wenn es kein Child-Fenster ist, dann zu einem machen
                    $pos = WinGetPos($hGUITool) ; alte Position speichern
                    _WinAPI_SetParent($hGUITool,0) ; Parent entfernen
                    WinMove($hGUITool,"",$pos[0],$pos[1],$Toolbarfenster[2],$Toolbarfenster[3]) ; an alte Position schieben
                    GUISetStyle($WS_SYSMENU+$WS_CAPTION,$WS_EX_TOOLWINDOW,$hGUITool) ; neuer Style
                Case -3
                    GUISetStyle(BitOR($WS_CHILD,$WS_BORDER),0,$hGUITool) ; den Style ändern
                    _WinAPI_SetParent($hGUITool, $hGUIMain) ; einbetten
                    WinMove($hGUITool,"",0,0,$Toolbar_breite,$Toolbar_hoehe) ; an 0,0 des Hauptfensters schieben
                    _WinAPI_RedrawWindow($hGUITool) ; neu zeichenen
                    _WinAPI_RedrawWindow($hGUIMain) ; neu zeichenen
            EndSwitch
    EndSwitch
WEnd

  should help to explore the needed functions.

Link to comment
Share on other sites

Great idea! It works fine but there is a title and some other windows stuff.

#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>

$hGUIMain = GUICreate("Parent", 800, 600)
GUISetState(@SW_SHOW, $hGUIMain)

Opt("WinTitleMatchMode", 2)

$hGUITool = WinGetHandle("Firefox")
If $hGUITool = 0 Then
    MsgBox(0,"","Run firefox first!")
    Exit
EndIf

$Toolbarfenster = WinGetPos($hGUITool)
GUISetStyle(BitOR($WS_CHILD, $WS_BORDER), 0, $hGUITool) ; den Style ändern
_WinAPI_SetParent($hGUITool, $hGUIMain) ; einbetten
WinMove($hGUITool, "", 0, 0, 800, 600) ; an 0,0 des Hauptfensters schieben
_WinAPI_RedrawWindow($hGUITool) ; neu zeichenen
_WinAPI_RedrawWindow($hGUIMain) ; neu zeichenen

While 1
    $avMsg = GUIGetMsg(1)
    Switch $avMsg[1]
        Case $hGUIMain
            Switch $avMsg[0]
                Case -3
                    Exit
            EndSwitch
    EndSwitch
WEnd

oXXYwzE.png

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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