Jump to content
Sign in to follow this  
RDSchaefer

CLOSED-How to add a button to a toolbar in an other program

Recommended Posts

RDSchaefer

I have a great idea for a Firefox addon but I'd rather write it in AutoIt if possible.

Is there a way to add a button to the Firefox toolbar that would be controlled by my program?

Edited by RDSchaefer

Share this post


Link to post
Share on other sites
RobertKipling

If you're looking for a quick fix, create a tiny window that's topmost with a "toolbar button" on it that follows the closest Firefox around and positions itself over top.

Otherwise, sorry to say I've never written a plugin for Firefox in my life.

Share this post


Link to post
Share on other sites
Melba23

RDSchaefer,

The following is the code I used to create a small toobar on another application. I could not find any way of getting it to act as a proper child in Vista - so I went the overlay route as suggested by RobertKipling.

The toobar is created as a small pop-up with the TOPMOST style. Within the While...WEnd loop, it first checks if the app window has moved and if so, repositions itself. It then reactivates the app window when the toolbar is activated by being clicked on so that any subsequent actions take place on the app and not the toolbar! Finally, the toolbar hides when the app is not the active window - otherwise it would stay TOPMOST over something else! It means that the toolbar vanishes if the app is visible and not active - but I could not think of any other way to do it. ;-)

Anyway, feel free to plunder this as much as you want:

Global $fToolBar_Vis = True, $iLast_X = -99999, $iLast_Y = -99999

; -------

; Create ToolBar GUI
Global $hToolBar = GUICreate("ToolBar", 300, 18, Default, Default, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)

; -------

While 1

    ; Check App still running
    If Not WinExists($hApp_Wnd) Then Exit
    
    $iMsg = GUIGetMsg()
    
    If $iMsg = $GUI_EVENT_CLOSE Or $iMsg = $hExit_Icon Then Exit
    
    ; Correct position of window if required
    If WinActive($hApp_Wnd) Or WinActive($hToolBar) Then
        $aApp_Pos = WinGetPos($hApp_Wnd)
        If $aApp_Pos[0] <> $iLast_X Or $aApp_Pos[1] <> $iLast_Y Then
            $iLast_X = $aApp_Pos[0]
            $iLast_Y = $aApp_Pos[1]
            $aApp_Client_Size = WinGetClientSize($hApp_Wnd)
            ; You will need to adjust the position to fit your app, of course
            WinMove($hToolBar, '', $aApp_Pos[0] + 360, $aApp_Pos[1] + ($aApp_Pos[3] - $aApp_Client_Size[1]) - 5, $iToolBar_Width, 18)
            GUISetState(@SW_SHOW)
        EndIf
    EndIf
    
    ; Reactivate App when Button window is activated
    If WinActive($hToolBar) Then 
        WinActivate($hApp_Wnd)
    EndIf
    
    ; Hide ToolBar when App not active
    If BitAND(WinGetState($hApp_Wnd), 8) <> 8 And $fToolBar_Vis = True Then
        GUISetState(@SW_HIDE, $hToolBar)
        $fToolBar_Vis = False
    ElseIf BitAND(WinGetState($hApp_Wnd), 8) = 8 And $fToolBar_Vis = False Then
        GUISetState(@SW_SHOW, $hToolBar)
        $fToolBar_Vis = True
    EndIf
    
    ; -------
    
WEnd

Exit

And if you ever find out how to get the toolbar to act as a real child in Vista - please let me know!

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
RDSchaefer

The following is the code...

And if you ever find out how to get the toolbar to act as a real child in Vista - please let me know!

M23

Wow, thanks a lot. Not exactly what I was looking for but it will sure help. BTW - I neither use nor support Vista so if you have something else for XP I'm all ears (eyes?).

Share this post


Link to post
Share on other sites
Melba23

Zedna,

I hope it helps the OP, but I could not get the anygui UDF to work in Vista. Have you had any luck? I imagine it is Vista doing its "each app in a separate area" security thing, so I am not optimistic. :-(

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
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
Sign in to follow this  

×