Embedded Firefox Objekt?

  • [autoit]

    _IECreateEmbedded()
    _FFCreateEmbedded();das will er! (oder?)

    [/autoit]

    MfG. tobi_girst

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »tobi_girst« (Morgen, 25:63)

  • Hat er ja nicht gesagt, nur auf eine Seite mit tausenderlei Möglichkeiten verwiesen :D - ich rate halt ungern.
    Aber zu was braucht man den das? Also für welche ernsthafte Anwendung?

    Um einen "Browser" zu basteln? =>
    http://www.autoitscript.com/forum/index.php?showtopic=95595&view=findpost&p=712377

    [EDIT]
    Browser:

    Spoiler anzeigen
    [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

    ;main window
    Global $hWnd

    [/autoit] [autoit][/autoit] [autoit]

    ;FF window
    Global $hWndFF

    [/autoit] [autoit][/autoit] [autoit]

    ;Zoom value
    Global $ZoomValue = 1.1

    [/autoit] [autoit][/autoit] [autoit]

    ;window dimensions
    Global $WGui = 640
    Global $HGui = 580
    Global $XBr = 10
    Global $YBr = 80
    Global $WBr = 620
    Global $HBr = 490

    [/autoit] [autoit][/autoit] [autoit]

    Global $DefaultFolder = @ScriptDir & "\"
    Global $StartURL = "www.google.com"

    [/autoit] [autoit][/autoit] [autoit]

    $hWnd = GUICreate ( "AFireFox", $WGui, $HGui,10, 10, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPCHILDREN)

    _GUISetIcon($hWnd, $sFFExe, -3)

    [/autoit] [autoit][/autoit] [autoit]

    ; get sizes of client area
    $Rect = WinGetClientSize($hwnd)

    [/autoit] [autoit][/autoit] [autoit]

    ; Create Buttons
    $GUI_Home = GuiCtrlCreateButton("Home", 10, 10, 50, 25)
    GUICtrlSetResizing (-1, $GUI_DOCKALL)
    GUICtrlSetTip(-1, "Go to Home page")
    $GUI_Back = GuiCtrlCreateButton("Back", 60, 10, 50, 25)
    GUICtrlSetResizing (-1, $GUI_DOCKALL)
    GUICtrlSetTip(-1, "Go to previous page")
    $GUI_Forward = GuiCtrlCreateButton("Forward", 110,10, 50, 25)
    GUICtrlSetResizing (-1, $GUI_DOCKALL)
    GUICtrlSetTip(-1, "Go to next page")
    $GUI_Stop = GuiCtrlCreateButton("Stop", 160, 10, 50, 25)
    GUICtrlSetResizing (-1, $GUI_DOCKALL)
    GUICtrlSetTip(-1, "Stop laoding")
    $GUI_ZoomP = GuiCtrlCreateButton("(+)", 210, 10, 25, 25)
    GUICtrlSetResizing (-1, $GUI_DOCKALL)
    GUICtrlSetTip(-1, "Zoom in")
    $GUI_ZoomM = GuiCtrlCreateButton("(-)", 235, 10, 25, 25)
    GUICtrlSetResizing (-1, $GUI_DOCKALL)
    GUICtrlSetTip(-1, "Zoom out")
    $GUI_Reset = GuiCtrlCreateButton("Reset", 260, 10, 50, 25)
    GUICtrlSetResizing (-1, $GUI_DOCKALL)
    $GUI_Restore = GuiCtrlCreateButton("Restore", 310, 10, 50, 25)
    GUICtrlSetResizing (-1, $GUI_DOCKALL)
    $GUI_Search = GuiCtrlCreateButton("Search", 360, 10, 50, 25)
    GUICtrlSetResizing (-1, $GUI_DOCKALL)
    GUICtrlSetTip(-1, "Open Search dialog")
    $GUI_Print = GuiCtrlCreateButton("Print", 410, 10, 50, 25)
    GUICtrlSetResizing (-1, $GUI_DOCKALL)
    $GUI_Config = GuiCtrlCreateButton("Config", 460, 10, 50, 25)
    GUICtrlSetResizing (-1, $GUI_DOCKALL)
    GUICtrlSetTip(-1, "Open Configuration dialog")
    $GUI_About = GuiCtrlCreateButton("About", 510, 10, 50, 25)
    GUICtrlSetResizing (-1, $GUI_DOCKALL)
    GUICtrlSetTip(-1, "About FifeFox page")

    [/autoit] [autoit][/autoit] [autoit]

    ; Create input control
    $GUI_Input_Label = GuiCtrlCreateLabel("URL:", 30, 55, 30, 20)
    GUICtrlSetResizing (-1, $GUI_DOCKALL)
    $GUI_Input = GuiCtrlCreateInput($StartURL, 65, 50, 295, 20)
    GUICtrlSetResizing (-1, $GUI_DOCKALL)
    $GUI_Go = GuiCtrlCreateButton("Go", 365, 50, 50, 20)
    GUICtrlSetResizing (-1, $GUI_DOCKALL)
    GUICtrlSetTip(-1, "Go to URL")
    $GUI_Browse = GuiCtrlCreateButton("Browse", 420, 50, 50, 20)
    GUICtrlSetResizing (-1, $GUI_DOCKALL)
    GUICtrlSetTip(-1, "Browse file")

    [/autoit] [autoit][/autoit] [autoit]

    ;=======================================
    ; Thanks to:
    ; http://www.autoitscript.com/forum/index.php?showtopic=95151
    $Dum = GUICtrlCreateDummy()
    Dim $Accels[1][2] = [["{ENTER}", $Dum]]
    GUISetAccelerators($Accels)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    $hWndFF = _FF_CreateEmbedded($hWnd, $XBr, $YBr, $WBr, $HBr)

    [/autoit] [autoit][/autoit] [autoit]

    _FFOpenURL("about:blank")

    [/autoit] [autoit][/autoit] [autoit]

    While True
    $msg = GUIGetMsg()

    Select
    Case $msg = $GUI_EVENT_CLOSE
    ExitLoop
    Case $msg = $GUI_Go or $msg = $Dum
    $URL = GUICtrlRead($GUI_Input)
    _FFOpenURL($URL)
    $URL = _FFCmd(".location.href")
    GUICtrlSetData($GUI_Input,$URL)
    Case $msg = $GUI_About
    _FFAction("About", "")
    $URL = _FFCmd(".location.href")
    GUICtrlSetData($GUI_Input,$URL)
    Case $msg = $GUI_Config
    _FFOpenURL("about:config")
    $URL = _FFCmd(".location.href")
    GUICtrlSetData($GUI_Input,$URL)
    Case $msg = $GUI_Back
    _FFAction("Back", "")
    $URL = _FFCmd(".location.href")
    GUICtrlSetData($GUI_Input,$URL)
    Case $msg = $GUI_Forward
    _FFAction("Forward", "")
    $URL = _FFCmd(".location.href")
    GUICtrlSetData($GUI_Input,$URL)
    Case $msg = $GUI_Home
    _FFAction("Home", "")
    $URL = _FFCmd(".location.href")
    GUICtrlSetData($GUI_Input,$URL)
    Case $msg = $GUI_Stop
    _FFAction("Stop", "")
    $URL = _FFCmd(".location.href")
    GUICtrlSetData($GUI_Input,$URL)
    Case $msg = $GUI_ZoomP
    $ZoomValue += 0.1
    _FFAction("Zoom", $ZoomValue)
    Case $msg = $GUI_ZoomM
    If $ZoomValue > 0.5 then $ZoomValue -= 0.1
    _FFAction("Zoom", $ZoomValue)
    Case $msg = $GUI_Reset
    _FFAction("Reset", "")
    Case $msg = $GUI_Restore
    TrickRestore()
    Case $msg = $GUI_Search
    _FFAction("Search", "")
    WinActivate("[CLASS:MozillaDialogClass]","")
    Case $msg = $GUI_Print
    _FFAction("Print", "")
    WinActivate("[CLASS:#32770]","")
    Case $msg = $GUI_Browse
    $URL = FileOpenDialog("Select any file to browse", @WorkingDir, "All files (*.*)", 1)
    if not @error then
    if StringInStr ($URL,'\') then $URL = _PathToURL($URL)
    _FFOpenURL($URL)
    $URL = _FFCmd(".location.href")
    GUICtrlSetData($GUI_Input,$URL)
    endif

    EndSelect

    $Rect_New = WinGetClientSize($hwnd)
    if not @error and ($Rect_New[0] <> $Rect[0] or $Rect_New[1] <> $Rect[1]) then
    $Rect = $Rect_New
    WinMove($hWndFF, "", $XBr, $YBr, $rect[0] - 2*$XBr, $rect[1] - $YBr - $XBr)
    endif
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ;=============================
    ; take care!
    ; to escape error on close you should set
    ; pref option value "browser.tabs.warnOnClose" to false

    [/autoit] [autoit][/autoit] [autoit]

    $prefValue = "browser.tabs.warnOnClose"
    _FFPrefSet($prefValue, "false")

    [/autoit] [autoit][/autoit] [autoit]

    ;MsgBox(64, $prefValue, "Old value: " & @extended & @CrLf & "New value: " & _FFPrefGet($prefValue))

    [/autoit] [autoit][/autoit] [autoit]

    ;and carefully close embedded FF window
    WinClose($hWndFF)

    [/autoit] [autoit][/autoit] [autoit]

    _FFQuit()
    GUIDelete()
    exit

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    Func TrickRestore()
    _FFOpenURL("about:blank")
    _FFAction("Back", "")
    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    WinSetOnTop($hGUI,"",1)

    [/autoit] [autoit][/autoit] [autoit]

    Run($sFFExe & ' -P "default" -new-window "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

    [/autoit] [autoit][/autoit] [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

    _FFWindowSelect()

    [/autoit] [autoit][/autoit] [autoit]

    Local $hFF = _FFWindowGetHandle()

    [/autoit] [autoit][/autoit] [autoit]

    ; This doesn't work correctly!
    ; GUISetStyle(BitOR($WS_POPUP, $WS_SIZEBOX), $WS_EX_MDICHILD, $hFF)

    [/autoit] [autoit][/autoit] [autoit]

    ; This one works!
    _FFStyle($hFF, BitOR($WS_POPUP, $WS_SIZEBOX),$WS_EX_MDICHILD)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    WinMove($hFF, "", $x, $y, $w, $h)

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

    [/autoit] [autoit][/autoit] [autoit]

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

    WinSetOnTop($hGUI,"",0)

    [/autoit] [autoit][/autoit] [autoit]

    Return $hFF
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;=================================================================================
    ; from
    ; http://www.autoitscript.com/forum/index.php?showtopic=96930
    Func _GUISetIcon($hGui, $sModule, $iName)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetIcon($sModule, $iName, $hGui)

    [/autoit] [autoit][/autoit] [autoit]

    Local $a_hCall = DllCall("user32.dll", "lresult", "SendMessageW", _
    "hwnd", $hGui, _
    "dword", 0x007F, _; WM_GETICON
    "wparam", 0, _; 1 = ICON_BIG, 0 = ICON_SMALL
    "lparam", 0)
    DllCall("user32.dll", "lresult", "SendMessageW", _
    "hwnd", $hGui, _
    "dword", 0x0080, _; WM_SETICON
    "wparam", 1, _; 1 = ICON_BIG, 0 = ICON_SMALL
    "lparam", $a_hCall[0])

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;=================================================================================
    ; create URL for any files
    Func _PathToURL($Path)
    $Parts = StringSplit(StringStripWS($Path,3),"\")
    $Res = "file:///"
    if StringRight($Parts[$Parts[0]],4) = ".chm" then $Res = "chm:file://"
    for $i = 1 to $Parts[0]
    $Text = StringSplit(BinaryToString(StringToBinary($Parts[$i],4),1),"")
    For $j = 1 To $Text[0]
    $nChar = Asc($Text[$j])
    Switch $nChar
    Case 45, 46, 48 to 58, 65 To 90, 95, 97 To 122, 126
    $Res &= $Text[$j]
    Case Else
    $Res &= "%" & Hex($nChar,2)
    EndSwitch
    Next
    if $i <> $Parts[0] then $Res &= "%5C"
    next
    return $Res
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;===================================
    ;Set FF window style
    func _FFStyle($hWnd, $Style=-1, $ExStyle=-1)
    local $GWL_STYLE = -16, $GWL_EXSTYLE = -20
    ;if $Style = -1 then $Style = BitOR($WS_POPUP, $WS_SIZEBOX)
    if $Style = -1 then $Style = BitOR($WS_CHILD, $WS_SIZEBOX)
    $res = DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "int", $Style)
    if $ExStyle <> -1 then $res = DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_EXSTYLE, "int", $ExStyle)
    DllCall("user32.dll", "int", "SetWindowPos", "hwnd", $hWnd, "hwnd", 0, "int", 0, "int", 0, "int", 0, "int", 0, "int", 0x47)
    endfunc

    [/autoit]

    Einmal editiert, zuletzt von Stilgar (8. September 2009 um 17:21)

  • Guten Tag,
    Mal so als Frage. Wieso will das hier nicht funktionieren?

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #include <WindowsConstants.au3>
    $oIE = ObjCreate("Mozilla.Browser.1")

    [/autoit] [autoit][/autoit] [autoit]

    ; Create a simple GUI for our output
    GUICreate ( "Embedded Web control Test", 640, 580,(@DesktopWidth-640)/2, (@DesktopHeight-580)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
    $GUIActiveX = GUICtrlCreateObj ( $oIE, 10, 40 , 600 , 360 )
    $GUI_Button_Back = GuiCtrlCreateButton ("Back", 10, 420, 100, 30)
    $GUI_Button_Forward = GuiCtrlCreateButton ("Forward", 120, 420, 100, 30)
    $GUI_Button_Home = GuiCtrlCreateButton ("Home", 230, 420, 100, 30)
    $GUI_Button_Stop = GuiCtrlCreateButton ("Stop", 330, 420, 100, 30)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState () ;Show GUI

    [/autoit] [autoit][/autoit] [autoit]

    $oIE.navigate("about:")

    [/autoit] [autoit][/autoit] [autoit]

    ; Waiting for user to close the window
    While 1
    $msg = GUIGetMsg()

    [/autoit] [autoit][/autoit] [autoit]

    Select
    Case $msg = $GUI_EVENT_CLOSE
    $oIE = 0
    ExitLoop
    Case $msg = $GUI_Button_Home
    $oIE.navigate("http://www.autoitscript.com")
    Case $msg = $GUI_Button_Back
    $oIE.GoBack
    Case $msg = $GUI_Button_Forward
    $oIE.GoForward
    Case $msg = $GUI_Button_Stop
    $oIE.Stop
    EndSelect

    [/autoit] [autoit][/autoit] [autoit]

    Wend

    [/autoit] [autoit][/autoit] [autoit]

    GUIDelete ()

    [/autoit] [autoit][/autoit] [autoit]

    Exit

    [/autoit]

    Hab auch das Programm hier heruntergeladen und installiert. :S

  • Also erstmal sry hab was falsch beschrieben. Bei diesem Script wird eine weiße Fläche bei mir erstellt (COM-Objekt). Das Problem daran ist, dass man damit keine Seite wie "www.google.de" öffnen kann.

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    ; Example: Embedding an Mozilla Object inside an AutoIt GUI
    ; Download Mozilla ActiveX Control
    ; from http://www.brothersoft.com/mozilla-active…load-78221.html

    [/autoit] [autoit][/autoit] [autoit]

    $Mozilla = ObjCreate("Mozilla.Browser.1") ; Get the Mozilla ActiveX instance
    If Not IsObj($Mozilla) Then
    MsgBox(0, "Mozilla", "Can't find Mozilla ActiveX Control")
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ; Create a simple GUI for our output
    GUICreate("Embedded Mozilla Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
    $GUIActiveX = GUICtrlCreateObj($Mozilla, 10, 40, 600, 360)
    $GUI_Button_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30)
    $GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30)
    $GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30)
    $GUI_Button_Stop = GUICtrlCreateButton("Stop", 330, 420, 100, 30)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState() ;Show GUI

    [/autoit] [autoit][/autoit] [autoit]

    $Mozilla.navigate("http://www.autoitscript.com/forum/index.php?showtopic=95595") ;Klappt nicht -.-
    ;~ MsgBox(0, "", $Mozilla.Path())

    [/autoit] [autoit][/autoit] [autoit]

    ; Waiting for user to close the window
    While 1
    $msg = GUIGetMsg()

    [/autoit] [autoit][/autoit] [autoit]

    Select
    Case $msg = $GUI_EVENT_CLOSE
    ExitLoop
    Case $msg = $GUI_Button_Home
    $Mozilla.navigate("http://www.autoitscript.com/forum/")
    Case $msg = $GUI_Button_Back
    $Mozilla.GoBack
    Case $msg = $GUI_Button_Forward
    $Mozilla.GoForward
    Case $msg = $GUI_Button_Stop
    $Mozilla.Stop
    EndSelect

    [/autoit] [autoit][/autoit] [autoit]

    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    $Mozilla = 0
    GUIDelete()

    [/autoit] [autoit][/autoit] [autoit]

    Exit

    [/autoit]
  • Keine Ahnung hier funktioniert es - trotz Vista.

    Ganz schön aufwendig - 169 Dateien für ein bisschen Fenster :D
    Aber der komplette Zugriff auf FireFox wird wohl verwehrt bleiben, es hat die gleiche API wie der IE - also weit kommt damit nicht.

  • Unter Vista sehen die alle aus.

    Aber es schon ein FF-Fenster, kannst ja mal als Adresse:
    javascript:document.write(navigator.userAgent);
    eingeben.
    Nur dank IE-API gibts allerdings auch nur das Context-Menü vom IE .

    [EDIT]
    1111 Beitrag :D

  • bei mir kommt da:

    [autoit]

    $Mozilla = ObjCreate("Mozilla.Browser.1") ; Get the Mozilla ActiveX instance
    If Not IsObj($Mozilla) Then
    MsgBox(0, "Mozilla", "Can't find Mozilla ActiveX Control")
    EndIf

    [/autoit]

    immer ein fehler das mozilla nicht installiert ist aber ich benutze immer mozilla und habe es auch installiert also keine Portable

    [autoit]


    #cs-----------------------------------------------------------------------------
    Hilfe ist immer gut also nimmt sie an ^^
    #ce-----------------------------------------------------------------------------

    [/autoit]
  • Hi es ist wieder möglich mit Mozilla ActiveX Control 1.7.12

    Spoiler anzeigen
    [autoit]

    ; *************************************************************************; Example: Embedding an Mozilla Object inside an AutoIt GUI; Standalone Mozilla ActiveX Control installers. Note these contain just; the control and the parts of Mozilla Gecko it needs to function.; It does not contain the full Mozilla browser.; Download Mozilla ActiveX Control; from: http://www.iol.ie/~locka/mozilla/control.htm; Version: http://www.iol.ie/~locka/mozilla/MozillaControl177.exe; *************************************************************************;#include #include $oFF = ObjCreate("Mozilla.Browser.1")
    ; Create a simple GUI for our outputGUICreate ( "Embedded Web control Test", 640, 580,(@DesktopWidth-640)/2, (@DesktopHeight-580)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)$GUIActiveFF= GUICtrlCreateObj ( $oFF, 10, 40 , 600 , 360 )$GUI_Button_Back = GuiCtrlCreateButton ("Back", 10, 420, 100, 30)$GUI_Button_Forward = GuiCtrlCreateButton ("Forward", 120, 420, 100, 30)$GUI_Button_Home = GuiCtrlCreateButton ("Home", 230, 420, 100, 30)$GUI_Button_Stop = GuiCtrlCreateButton ("Stop", 330, 420, 100, 30)
    GUISetState () ;Show GUI
    $oFF.navigate("about:")
    ; Waiting for user to close the windowWhile 1$msg = GUIGetMsg()
    SelectCase $msg = $GUI_EVENT_CLOSE$oFF = 0ExitLoopCase $msg = $GUI_Button_Home$oFF.navigate("http://www.autoitscript.com")Case $msg = $GUI_Button_Back$oFF.GoBackCase $msg = $GUI_Button_Forward$oFF.GoForwardCase $msg = $GUI_Button_Stop$oFF.StopEndSelect
    Wend
    GUIDelete ()
    Exit

    [/autoit]