Jump to content

FF.au3 (V0.6.0.1b-10)


Stilgar
 Share

Recommended Posts

@Stilgar

Still late but no stars on this topic... :)

In this way its 5 stars for me because this UDF is very helpful for automate tasks and you have personally helped me !

Thank you mate ;)

Edit : Today I can use functions easily because I know how to use them :)

Cheers, FireFox.

Edited by FireFox
Link to comment
Share on other sites

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.

The point of world view

Link to comment
Share on other sites

Fixed FF_Browser.au3 (with native FF icon) has a following source:

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

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

;main window
Global $hWnd

;FF window
Global $hWndFF

;Zoom value
Global $ZoomValue = 1.1

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


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

; Create Buttons
$GUI_Go = GuiCtrlCreateButton("Go", 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_ZoomP = GuiCtrlCreateButton("(+)", 260, 10, 25, 25)
$GUI_ZoomM = GuiCtrlCreateButton("(-)", 285, 10, 25, 25)
$GUI_Reset = GuiCtrlCreateButton("Reset", 310, 10, 50, 25)
$GUI_Restore = GuiCtrlCreateButton("Restore", 360, 10, 50, 25)
$GUI_Alert = GuiCtrlCreateButton("Alert", 410, 10, 50, 25)
$GUI_Search = GuiCtrlCreateButton("Search", 460, 10, 50, 25)
$GUI_Print = GuiCtrlCreateButton("Print", 510, 10, 50, 25)
$GUI_About = GuiCtrlCreateButton("About", 560, 10, 50, 25)

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

GUISetState()

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

While True
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
           ExitLoop
        Case $msg = $GUI_Go
           $URL = GUICtrlRead($GUI_Input)
           _FFOpenURL($URL)
        Case $msg = $GUI_About
           _FFAction("About", "")
        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_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", "")
           TrickRestore()
        Case $msg = $GUI_Restore
           TrickRestore()
        Case $msg = $GUI_Search
           _FFAction("Search", "")
           TrickRestore()
        Case $msg = $GUI_Print
           _FFAction("Print", "")
           TrickRestore()
        Case $msg = $GUI_Alert
           $Message = GUICtrlRead($GUI_Input)
           _FFAction("Alert", $Message)
           TrickRestore()
    EndSelect
WEnd

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

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

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

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

_FFQuit()
GUIDelete()
exit

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


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


    WinSetOnTop($hGUI,"",1)

    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

    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

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

    GUISetIcon($sModule, $iName, $hGui)

    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])

EndFunc

@Stilgar

This script opens new FF window and close it before exit.

Early problems with closing fixed by setting profile's value "browser.tabs.warnOnClose" to false.

WinKill kills any existing FF windows!

The point of world view

Link to comment
Share on other sites

AFireFox.au3 code:

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

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

;main window
Global $hWnd

;FF window
Global $hWndFF

;Zoom value
Global $ZoomValue = 1.1

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

Global $DefaultFolder = @ScriptDir & "\"

$hWnd = GUICreate ( "AFireFox", $WGui, $HGui,(@DesktopWidth-$WGui)/2, (@DesktopHeight-$HGui)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
_GUISetIcon($hWnd, $sFFExe, -3)

; Create Buttons
$GUI_Go = GuiCtrlCreateButton("Go", 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_ZoomP = GuiCtrlCreateButton("(+)", 260, 10, 25, 25)
$GUI_ZoomM = GuiCtrlCreateButton("(-)", 285, 10, 25, 25)
$GUI_Reset = GuiCtrlCreateButton("Reset", 310, 10, 50, 25)
$GUI_Restore = GuiCtrlCreateButton("Restore", 360, 10, 50, 25)
$GUI_Alert = GuiCtrlCreateButton("Alert", 410, 10, 50, 25)
$GUI_Search = GuiCtrlCreateButton("Search", 460, 10, 50, 25)
$GUI_Print = GuiCtrlCreateButton("Print", 510, 10, 50, 25)
$GUI_About = GuiCtrlCreateButton("About", 560, 10, 50, 25)

; Create input control
$GUI_Input_Label = GuiCtrlCreateLabel("URL:", 30, 55, 30, 20)
$GUI_Input = GuiCtrlCreateInput("www.google.com", 60, 50, 300, 20)
GUICtrlSetResizing ($GUI_Input, $GUI_DOCKALL)
$GUI_Browse = GuiCtrlCreateButton("Browse", 365, 50, 50, 20)


GUISetState()

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

While True
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
           ExitLoop
        Case $msg = $GUI_Go
           $URL = GUICtrlRead($GUI_Input)
           _FFOpenURL($URL)
        Case $msg = $GUI_About
           _FFAction("About", "")
        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_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", "")
           TrickRestore()
        Case $msg = $GUI_Restore
           TrickRestore()
        Case $msg = $GUI_Search
           _FFAction("Search", "")
           TrickRestore()
        Case $msg = $GUI_Print
           _FFAction("Print", "")
           TrickRestore()
        Case $msg = $GUI_Alert
           $Message = GUICtrlRead($GUI_Input)
           _FFAction("Alert", $Message)
           TrickRestore()
        Case $msg = $GUI_Browse
           $URL = FileOpenDialog("Select any file to browse", @WorkingDir, "All files (*.*)", 1)
           if StringInStr ($URL,'\') then $URL = _PathToURL($URL)
;           MsgBox(0,"","$URL = " & $URL)
           GUICtrlSetData($GUI_Input,$URL)
           _FFOpenURL($URL)
    EndSelect
WEnd

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

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

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

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

_FFQuit()
GUIDelete()
exit

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


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


    WinSetOnTop($hGUI,"",1)

    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

    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

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

    GUISetIcon($sModule, $iName, $hGui)

    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])

EndFunc

;=================================================================================
; create URL for files
Func _PathToURL($Path)
 $Parts = StringSplit(StringStripWS($Path,3),"\")
 $Res = "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-57, 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 &= "/"
 next
 return $Res
EndFunc

It can browse local files - .pdf, .txt, .htm, .xml (incl. Mathematica).

The point of world view

Link to comment
Share on other sites

AFireFox.au3 is adaptive to window size.

Buttons (+) and (-) are for zoom in and zoom out actions.

To restore hidden image use button restore.

It's good idea to change www.google.com here.

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

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

;main window
Global $hWnd

;FF window
Global $hWndFF

;Zoom value
Global $ZoomValue = 1.1

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

Global $DefaultFolder = @ScriptDir & "\"

$hWnd = GUICreate ( "AFireFox", $WGui, $HGui,10, 10, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
_GUISetIcon($hWnd, $sFFExe, -3)

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

; Create Buttons
$GUI_Go = GuiCtrlCreateButton("Go", 10, 10, 50, 25)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
$GUI_Back = GuiCtrlCreateButton("Back", 60, 10, 50, 25)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
$GUI_Forward = GuiCtrlCreateButton("Forward", 110,10, 50, 25)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
$GUI_Home = GuiCtrlCreateButton("Home", 160, 10, 50, 25)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
$GUI_Stop = GuiCtrlCreateButton("Stop", 210, 10, 50, 25)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
$GUI_ZoomP = GuiCtrlCreateButton("(+)", 260, 10, 25, 25)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
$GUI_ZoomM = GuiCtrlCreateButton("(-)", 285, 10, 25, 25)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
$GUI_Reset = GuiCtrlCreateButton("Reset", 310, 10, 50, 25)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
$GUI_Restore = GuiCtrlCreateButton("Restore", 360, 10, 50, 25)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
$GUI_Alert = GuiCtrlCreateButton("Alert", 410, 10, 50, 25)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
$GUI_Search = GuiCtrlCreateButton("Search", 460, 10, 50, 25)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
$GUI_Print = GuiCtrlCreateButton("Print", 510, 10, 50, 25)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
$GUI_About = GuiCtrlCreateButton("About", 560, 10, 50, 25)
GUICtrlSetResizing (-1, $GUI_DOCKALL)

; Create input control
$GUI_Input_Label = GuiCtrlCreateLabel("URL:", 30, 55, 30, 20)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
$GUI_Input = GuiCtrlCreateInput("www.google.com", 60, 50, 300, 20)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
$GUI_Browse = GuiCtrlCreateButton("Browse", 365, 50, 50, 20)
GUICtrlSetResizing (-1, $GUI_DOCKALL)


GUISetState()

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

While True
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
           ExitLoop
        Case $msg = $GUI_Go
           $URL = GUICtrlRead($GUI_Input)
           _FFOpenURL($URL)
        Case $msg = $GUI_About
           _FFAction("About", "")
        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_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", "")
           TrickRestore()
        Case $msg = $GUI_Restore
           TrickRestore()
        Case $msg = $GUI_Search
           _FFAction("Search", "")
           TrickRestore()
        Case $msg = $GUI_Print
           _FFAction("Print", "")
           TrickRestore()
        Case $msg = $GUI_Alert
           $Message = GUICtrlRead($GUI_Input)
           _FFAction("Alert", $Message)
           TrickRestore()
        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)
             GUICtrlSetData($GUI_Input,$URL)
             _FFOpenURL($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

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

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

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

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

_FFQuit()
GUIDelete()
exit

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


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


    WinSetOnTop($hGUI,"",1)

    Run($sFFExe & ' new-window "about:blank" -P "default"', "", @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

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

    GUISetIcon($sModule, $iName, $hGui)

    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])

EndFunc

;=================================================================================
; create URL for files
Func _PathToURL($Path)
 $Parts = StringSplit(StringStripWS($Path,3),"\")
 $Res = "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-57, 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 &= "/"
 next
 return $Res
EndFunc

The point of world view

Link to comment
Share on other sites

New version AFireFox.

Fixed FF redraw problem.

Added control tips.

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

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

;main window
Global $hWnd

;FF window
Global $hWndFF

;Zoom value
Global $ZoomValue = 1.1

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

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

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

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

; 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")

; 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")


GUISetState()

$hWndFF = _FF_CreateEmbedded($hWnd, $XBr, $YBr, $WBr, $HBr)
_FFOpenURL("file:///d:/Ivanov/sms/Home.html")

While True
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
           ExitLoop
        Case $msg = $GUI_Go
           $URL = GUICtrlRead($GUI_Input)
           _FFOpenURL($URL)
        Case $msg = $GUI_About
           _FFAction("About", "")
        Case $msg = $GUI_Config
           _FFOpenURL("about:config")
        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_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)
             GUICtrlSetData($GUI_Input,$URL)
             _FFOpenURL($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

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

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

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

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

_FFQuit()
GUIDelete()
exit

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


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


    WinSetOnTop($hGUI,"",1)

    Run($sFFExe & ' new-window "about:blank" -P "default"', "", @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

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

    GUISetIcon($sModule, $iName, $hGui)

    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])

EndFunc

;=================================================================================
; create URL for files
Func _PathToURL($Path)
 $Parts = StringSplit(StringStripWS($Path,3),"\")
 $Res = "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-57, 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 &= "/"
 next
 return $Res
EndFunc

Now we can build AFireFox instance on separate AutoIt's Tab, I think.

It would be useful for writing some presentation tools based on the tree-like structure.

i.e. Windows Help Viewer (hh.exe)

Any ideas?

Enjoy.

The point of world view

Link to comment
Share on other sites

New version AFireFox.

- Fixed _PathToURL($Path)

- Added view of *.chm files.

See description on this page.

To view *.chm file FireFox should have CHM Reader installed.

CHM Reader add-on (working with FireFox 3.5.1) can be downloaded from

here

AFireFox uses FF.au3 with modified function __FFIsURL (new URL with prefix "chm:file://"):

Func __FFIsURL(ByRef $URL)
    Return (StringRegExp($URL, '^^((ht|f)tp(s?)\:\/\/|~/|/)([\w]+:\w+@)?([a-zA-Z]{1}([\w\-]+\.)+([\w]{2,5}))(:[\d]{1,5})?((/?\w+/)+|/?)(\w+\.[\w]{3,4})?((\?\w+=\w+)?(&\w+=\w+)*)?') Or _
            StringRegExp($URL,'^^((ht|f)tp(s?)\:\/\/|~/|/)(\d{1,3}\.){3}\d{1,3}(:[\d]{1,5})?(/.*)?$') Or _
            StringLeft($URL, 6) = "about:" Or _
            StringLeft($URL, 7) = "chrome:" Or _
            StringLeft($URL, 10)= "localhost:" Or _
            StringLeft($URL, 8) = "file:///" Or _
            StringLeft($URL, 11) = "chm:file://")
EndFunc   ;==>__FFIsURL

File AFireFox.au3:

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

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

;main window
Global $hWnd

;FF window
Global $hWndFF

;Zoom value
Global $ZoomValue = 1.1

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

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

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

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

; 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")

; 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")
$GUI_CHMRead = GuiCtrlCreateButton("CHMRead", 475, 50, 80, 20)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
GUICtrlSetTip(-1, "Read CHM file")


GUISetState()

$hWndFF = _FF_CreateEmbedded($hWnd, $XBr, $YBr, $WBr, $HBr)
_FFOpenURL("file:///d:/Ivanov/sms/Home.html")

While True
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
           ExitLoop
        Case $msg = $GUI_Go
           $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
        Case $msg = $GUI_CHMRead
           $URL = FileOpenDialog("Select CHM file to browse", @WorkingDir, "CHM files (*.chm)", 1)
           if not @error then
             if StringInStr ($URL,'\') then $URL = _CHMPathToURL($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

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

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

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

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

_FFQuit()
GUIDelete()
exit

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


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


    WinSetOnTop($hGUI,"",1)

    Run($sFFExe & ' new-window "about:blank" -P "default"', "", @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

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

    GUISetIcon($sModule, $iName, $hGui)

    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])

EndFunc

;=================================================================================
; create URL for files
Func _PathToURL($Path)
 $Parts = StringSplit(StringStripWS($Path,3),"\")
 $Res = "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 57, 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

;=================================================================================
; create URL for CHM file
Func _CHMPathToURL($Path)
 $Parts = StringSplit(StringStripWS($Path,3),"\")
 $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

Now you can add to AutoIt script the treeview control for simple navigation through .chm doc.

The point of world view

Link to comment
Share on other sites

@Stilgar,

I have a script which does _FFConnect() and waits for commands. This works. But I need to check if we are still connected to MozRepl before each command, since Firefox could be closed. How can I tell if my script is still connected? I think a function like _FFIsConnected() would be good to have.

Does anyone have a way to do an unattented setup of MozRepl yet or will I have to develop this myself?

The easiest way to do it would probably be to create a Firefox profile that already has MozRepl installed and configured like you want, then deploy Firefox and that profile, and make sure Firefox is set to use it by default.

Link to comment
Share on other sites

New version of AFireFox.au3

- Add handle {Enter} for Input control. {Enter} = Go button press!

- Combine Browse and CHMRead button.

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

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

;main window
Global $hWnd

;FF window
Global $hWndFF

;Zoom value
Global $ZoomValue = 1.1

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

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

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

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

; 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")

; 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")

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

GUISetState()

$hWndFF = _FF_CreateEmbedded($hWnd, $XBr, $YBr, $WBr, $HBr)
_FFOpenURL("www.google.com")

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

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

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

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

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

_FFQuit()
GUIDelete()
exit

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


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


    WinSetOnTop($hGUI,"",1)

    Run($sFFExe & ' new-window "about:blank" -P "default"', "", @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

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

    GUISetIcon($sModule, $iName, $hGui)

    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])

EndFunc

;=================================================================================
; 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

Now you can create AutoIt script navigation panel i.e. for .chm doc reading.

The point of world view

Link to comment
Share on other sites

You can do it, I think.

See here:

_FFIsConnected

Hmm... you are right. I did not see this function because it is not in the following list in FF.au3:

#Region #CURRENT# ==============================================================
    ;_FFAction
    ;_FFClick
    ;_FFClickXY
    ;_FFCmd
    ;_FFConnect
    ;_FFDialogWait
    ;_FFDisConnect
...
    ;_FFGetValueByName
    ;_FFImageClick
    ;_FFImageGetBySize
    ;_FFLinkClick
...
    ;_FFWindowOpen
    ;_FFWindowSelect
    ;_FFWriteHTML
    ;_FFXPath
#EndRegion #CURRENT# ==============================================================

Thanks Valery!

Edited by cameltoe47
Link to comment
Share on other sites

This script AFireFox_Full.au3 shows how to embed full FireFox window into GUI:

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

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

;main window
Global $hWnd

;FF window
Global $hWndFF

;Zoom value
Global $ZoomValue = 1.1

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

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

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

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

; 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")

; 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")

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

GUISetState()

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

_FFOpenURL("about:blank")

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

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

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

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

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

_FFQuit()
GUIDelete()
exit

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


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


    WinSetOnTop($hGUI,"",1)

    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

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

    _FFWindowSelect()

    Local $hFF = _FFWindowGetHandle()

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

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


    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

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

    GUISetIcon($sModule, $iName, $hGui)

    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])

EndFunc

;=================================================================================
; 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

;===================================
;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

It doesn't use Presentation mode of FF. AFireFox_Full.au3 changes GUI style of FF by func _FFStyle, only.

It has here also installed add-on

hidemenubar-1.0.20090705-addons.xpi

to hide menu line (Alt key is to show it). You can hide also any panels and bars. After doing this installation the AFireFox_Full.au3 can be used like MS application hh.exe.

post-9395-12489571493675_thumb.jpg

The point of world view

Link to comment
Share on other sites

@FireFox:

Thank you!

@trinitrotoluen:

Have you tried the latest test-version, too?

@cameltoe47:

Ok _FFIsConnected isn't in the function list, but in the documentation:

http://english.documentation.ff-au3.thorsten-willert.de/

@Valery:

Nice example! Why don't you made a thread? So it's easier to find.

The "CHM Reader"-AddOn is only working up to FF3.0.x >_<

Link to comment
Share on other sites

@trinitrotoluen:

Have you tried the latest test-version, too?

Yes, 0.5.3.6b-2

[4188] __FFWaitForRepl ==> Error TCPSend / TCPRecv: TCPRecv :10053

[4188] _FFCmd ==> Error return value

[4188] _FFPrefGet ==> Invalid value: javascript.enabled

[4188] _FFPrefSet ==> No match: $sName: javascript.enabled

[4188] __FFSend ==> Error TCPSend / TCPRecv: TCPSend: try{FFau3.obj=Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);FFau3.obj.getPrefType("javascript.enabled");}catch(e){'_FFCmd_Err';};

[4188] _FFCmd ==> Error return value

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