Jump to content
Sign in to follow this  
JackDinn

need help with a rebar and a toolbar

Recommended Posts

JackDinn

Hi,

I could really do with some help trying to sort out my GUI's main toolbar. i have been using it as it is for a long while now but now that im internationalizing the project i really need to have another look at the toolbar because in other languages some of the button labels are quite long in comparison to English and this is causing some problems.

heres a demo of my toolbar as i have it atm :-

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#Tidy_Parameters=/rel
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <Constants.au3>
#include <EditConstants.au3>
#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiImageList.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <RebarConstants.au3>
#include <ToolbarConstants.au3>
#include <WindowsConstants.au3>
Global $hgui
Global $hReBar
$Debug_RB = False
_Main()
Func _Main()
    Local $btnExit, $hToolbar, $hInput
    Global $hReBar, $aStrings[5]
    Global Enum $Hruntest = 1000, $Hconfig, $hDisplayCSV, $H_netmon, $H_graphdisplay
    $hgui = GUICreate("Rebar", 900, 396, 0, -1, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))
    GUIRegisterMsg($WM_SIZE, "WM_SIZE")
    $hReBar = _GUICtrlRebar_Create($hgui, $CCS_TOP + $RBS_FIXEDORDER + $RBS_BANDBORDERS)
    $hToolbar = _GUICtrlToolbar_Create($hgui, $CCS_NORESIZE + $TBSTYLE_FLAT + $TBSTYLE_LIST, $TBSTYLE_EX_DOUBLEBUFFER)
    $hImage = _GUIImageList_Create(18, 18, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "shell32.dll", 55)
    _GUIImageList_AddIcon($hImage, @SystemDir & "shell32.dll", 130)
    _GUIImageList_AddIcon($hImage, @SystemDir & "shell32.dll", 131)
    _GUICtrlToolbar_SetImageList($hToolbar, $hImage)
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, 'some long text')
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, 'Config')
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, 'CSV')
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, 'Display')
    $aStrings[4] = _GUICtrlToolbar_AddString($hToolbar, "Netmon")
                                    ;group WITH autosize #############
;~     _GUICtrlToolbar_AddButton($hToolbar, $Hruntest, 0, 0, $BTNS_AUTOSIZE)
;~     _GUICtrlToolbar_AddButton($hToolbar, $Hconfig, 1, 1, $BTNS_AUTOSIZE)
;~     _GUICtrlToolbar_AddButton($hToolbar, $hDisplayCSV, 2, 2, $BTNS_AUTOSIZE)
;~     _GUICtrlToolbar_AddButton($hToolbar, $H_graphdisplay, 3, 3, $BTNS_AUTOSIZE)
;~     _GUICtrlToolbar_AddButton($hToolbar, $H_netmon, 4, 4, $BTNS_AUTOSIZE)
                                    ;group WITHOUT autosize #############
    _GUICtrlToolbar_AddButton($hToolbar, $Hruntest, 0, 0)
    _GUICtrlToolbar_AddButton($hToolbar, $Hconfig, 1, 1)
    _GUICtrlToolbar_AddButton($hToolbar, $hDisplayCSV, 2, 2)
    _GUICtrlToolbar_AddButton($hToolbar, $H_graphdisplay, 3, 3)
    _GUICtrlToolbar_AddButton($hToolbar, $H_netmon, 4, 4)
                                    ;END #############
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0, $RBBS_NOGRIPPER)
    $Input1 = _GUICtrlEdit_Create($hgui, "60", 0, 0, 20, 20, $ES_LEFT)
    _GUICtrlRebar_AddBand($hReBar, $Input1, 50, 100, 'Cycle time (Minutes)' & " :", 1, $RBBS_NOGRIPPER)
    $traybut = _GUICtrlButton_Create($hgui, 'Tray', 0, 0, 90, 28, $BS_DEFPUSHBUTTON)
    _GUICtrlRebar_AddBand($hReBar, $traybut, 90, 90, "", 2, $RBBS_NOGRIPPER)
    $btnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUISetState(@SW_SHOW)
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $btnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>_Main
Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam)
    If $hWnd = $hgui Then
        $wPos = WinGetPos($hgui)
        ControlMove($hgui, "", $hReBar, 0, 0, $wPos[2])
    EndIf
EndFunc   ;==>WM_SIZE

When its first run iv set a long string on the first button which causes all the other buttons to be the same size and therefore elongate the toolbar.

I found that i could use $BTNS_AUTOSIZE on the _GUICtrlToolbar_AddButton() (iv left the commented out lines to show this) and it looks much better but the toolbar itself is still the same lenth i.e. the right hand side button and input field will drop down to below the toolbar when the windows is resized smaller even when there is a lot of blank space left on the right hand side of the toolbar?

Also while im on this subject iv always tried to remove the line that runs horizontally along the top of the toolbar.

Can anyone help me get my toolbar & rebar in a better state :)

Cheers,

Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites
LarsJ

Hi JackDinn,

If you use _GUICtrlRebar_AddBand($hReBar, $hToolbar, 350, 350, "", 0) to add the toolbar you can define the width of the band.

The horizontal line along the top of the toolbar is an impact of the $CCS_NORESIZE flag. Remove this flag.

Removing this flag unfortunately means that the text "Cycle time (Minutes) :" will not be displayed. I don't know why.To overcome this problem use a child window in the second band with a label and an edit control.

(Using a child window in a band makes it possible to have several controls in a band (at least it looks like). Also a child window makes it easy to control the height of the ReBar. Just set the height of the window)

tst01.au3

Lars

Share this post


Link to post
Share on other sites
JackDinn

ahh thx for the response , much better that someone trying to sell me (& everyone) watches LOL.

really good advice about the _GUICtrlRebar_AddBand() instated of _GUICtrlRebar_AddToolBarBand() i just assumed that as its a toolbar i must use _GUICtrlRebar_AddToolBarBand() but tested and works great , thx .

I dont understand what you mean by child window in this case ? do you mean create another toolbar or rebar and add that or are you talking about a normal window ?

excellent stuff though , im so close now and in the grand scheme of things the line at the top is not the end of the world :)

Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites
JackDinn

hmm i tried with creating a "normal" GUI window and adding it with _GUICtrlRebar_AddBand($hReBar, $HGUI2, 50, 100,"", 1, $RBBS_NOGRIPPER) and thats give me some interesting stuff to tinker with , it put the whole GUI window into the rebar (cool :) ) so im just tinkering with removing the system bar from the GUI and see how we go.

I now assume you did mean to use a "normal" GUI window now,

good stuff thx.


Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites
JackDinn

hmm i can work with that for a bit (see what i can do with it) but what about the background colour of the child window ? i can set it to other colours but it wont match the rebar's skin colour and gradated affect (is a blue gradient on my win7).

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#Tidy_Parameters=/rel
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <Constants.au3>
#include <EditConstants.au3>
#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiImageList.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <RebarConstants.au3>
#include <ToolbarConstants.au3>
#include <WindowsConstants.au3>
Global $hgui
Global $hReBar
$Debug_RB = False
_Main()
Func _Main()
Local $btnExit, $hToolbar, $hInput
Global $hReBar, $aStrings[5]
Global Enum $Hruntest = 1000, $Hconfig, $hDisplayCSV, $H_netmon, $H_graphdisplay
$hgui = GUICreate("Rebar", 900, 396, 0, -1, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))
GUIRegisterMsg($WM_SIZE, "WM_SIZE")
$hReBar = _GUICtrlRebar_Create($hgui, $CCS_TOP + $RBS_FIXEDORDER + $RBS_BANDBORDERS)
$hToolbar = _GUICtrlToolbar_Create($hgui, $TBSTYLE_FLAT + $TBSTYLE_LIST, $TBSTYLE_EX_DOUBLEBUFFER)
$hImage = _GUIImageList_Create(18, 18, 5, 3)
_GUIImageList_AddIcon($hImage, @SystemDir & "shell32.dll", 137)
_GUIImageList_AddIcon($hImage, @SystemDir & "shell32.dll", 165)
_GUIImageList_AddIcon($hImage, @SystemDir & "shell32.dll", 55)
_GUIImageList_AddIcon($hImage, @SystemDir & "shell32.dll", 130)
_GUIImageList_AddIcon($hImage, @SystemDir & "shell32.dll", 131)
_GUICtrlToolbar_SetImageList($hToolbar, $hImage)
$aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, 'some long text')
$aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, 'Config')
$aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, 'CSV')
$aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, 'Display')
$aStrings[4] = _GUICtrlToolbar_AddString($hToolbar, "Netmon")
;group WITH autosize #############
_GUICtrlToolbar_AddButton($hToolbar, $Hruntest, 0, 0, $BTNS_AUTOSIZE)
_GUICtrlToolbar_AddButton($hToolbar, $Hconfig, 1, 1, $BTNS_AUTOSIZE)
_GUICtrlToolbar_AddButton($hToolbar, $hDisplayCSV, 2, 2, $BTNS_AUTOSIZE)
_GUICtrlToolbar_AddButton($hToolbar, $H_graphdisplay, 3, 3, $BTNS_AUTOSIZE)
_GUICtrlToolbar_AddButton($hToolbar, $H_netmon, 4, 4, $BTNS_AUTOSIZE)
;~ _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0, $RBBS_NOGRIPPER)
_GUICtrlRebar_AddBand($hReBar, $hToolbar, 400, 650, "", 0)

$HGUI2=GUICreate("www",300,20,0,0,$WS_POPUP,-1,$hReBar)
GUICtrlCreateLabel("Cycle time (mins)",0,0,100)
GUICtrlCreateInput("60",110,0)
_GUICtrlRebar_AddBand($hReBar, $HGUI2, 350, 100,"", 1, $RBBS_NOGRIPPER)
$traybut = _GUICtrlButton_Create($hgui, 'Tray', 0, 0, 90, 28, $BS_DEFPUSHBUTTON)
_GUICtrlRebar_AddBand($hReBar, $traybut, 90, 90, "", 2, $RBBS_NOGRIPPER)
$btnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
GUISetState(@SW_SHOW,$hgui)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $btnExit
Exit
EndSwitch
WEnd
EndFunc ;==>_Main
Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam)
If $hWnd = $hgui Then
$wPos = WinGetPos($hgui)
ControlMove($hgui, "", $hReBar, 0, 0, $wPos[2])
EndIf
EndFunc ;==>WM_SIZE

how am i going to get around this problem ?

P.S. sorry i didnt see your demo code before all my posting above , :-/, sorry

Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites
LarsJ

Have you tried just to make the child window transparent ($WS_EX_TRANSPARENT).

If you want no border at all at the top use

$hReBar = _GUICtrlRebar_Create($hGui, $CCS_TOP + $CCS_NODIVIDER + $RBS_FIXEDORDER + $RBS_BANDBORDERS)

Lars

Share this post


Link to post
Share on other sites
JackDinn

yea tried making the child window transparent and also tried making the controls background transparent , but unfortunately dont work, still a gray background :(

Is no problem iv been using it with the line at the top for years now , i'll just continue to do so.

My main problem is sorted though so many thx for that :)


Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

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  

  • Similar Content

    • ISI360
      By ISI360
      Hi!
      I currently have probelms trying to create a vertical toolbar with a rebar.
      The Controls create and works fine...until i change some state of it. Then it will mess up everything when the mouse is moving over the buttons.

      Please can someone explain me what i´m doing wrong here??
       
      #include <Constants.au3> #include <GuiButton.au3> #include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <GuiImageList.au3> #include <GuiReBar.au3> #include <GuiToolbar.au3> #include <WindowsConstants.au3> Global $hGui, $hGui2, $hReBar, $aStrings[5] Global Enum $Hruntest = 1000, $Hconfig, $hDisplayCSV, $H_netmon, $H_graphdisplay, $H_netmon1 $hGui = GUICreate("Rebar", 900, 396, 400, 200, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX)) $hImage = _GUIImageList_Create(16, 16, 5, 3) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 55) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 130) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 154) Global $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN, $TBSTYLE_WRAPABLE) ) _GUICtrlToolbar_SetImageList($hToolbar, $hImage) _GUICtrlToolbar_AddButton($hToolbar, $Hruntest, 0, 0,BitOR($BTNS_DROPDOWN, $BTNS_WHOLEDROPDOWN)) _GUICtrlToolbar_AddButton($hToolbar, $Hconfig, 1, 1 ) _GUICtrlToolbar_AddButton($hToolbar, $hDisplayCSV, 2, 2) _GUICtrlToolbar_AddButton($hToolbar, $H_graphdisplay, 3, 3) _GUICtrlToolbar_AddButton($hToolbar, $H_netmon, 4, 4) _GUICtrlToolbar_AddButton($hToolbar, $H_netmon1, 5, 5) $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $CCS_VERT, $RBS_FIXEDORDER )) _GUICtrlToolbar_SetButtonSize($hToolbar, 30 , 22 ) _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", -1, $RBBS_NOGRIPPER ) GUISetState(@SW_SHOW) MsgBox(0,"Demo","At the moment everything is ok. The vertical toolbar is created and works with no problems!"&@crlf&@crlf&"But now let us disable for example the first button...",0,$hGui) _GUICtrlToolbar_SetButtonState($hToolbar, $Hruntest, $TBSTATE_INDETERMINATE ) MsgBox(0,"Demo","...and now it´s getting buggy! :P"&@crlf&"Move the mouse over the buttons and see yourselfe... (after closing this dialog)",0,$hGui) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd

      Thanks in advance!
    • BrewManNH
      By BrewManNH
      I was looking for a toolbar modification for SciTE and I was checking various versions of SciTE that were available on the internet. They all had some problems for how I wanted to use the editor, so I looked here to see if there were any toolbar modifications for Scite. I found one very old script by YogiBear (Volly) from 2006 that looked promising, though there were issues with it. I decided to see what I could do to modify this script, and make some improvements to it if possible. This script is the result of that work.

      It's not perfect and definitely could use some tweaking, but I thought that it had matured enough, and was mostly stable enough to release the updated version.

      Changelog:
      Version 2.0.1
      Minor update to remove all the old Obfuscator directives and replaced them with #Au3Stripper directives instead. I also corrected a minor bug that only showed up for me on one computer I tried this on, and caused the tool bar to crash for others as well.
      SciTE toolbar version 2.0
      Changed the settings values to use constants instead of 'magic numbers' The icons on the toolbar weren't lining up with the separator characters or with the toolbar GUI because they weren't set with the resize setting for the icons, only for the separators. Changed to using arrays for everything, it makes it a lot easier to loop through the controls Added a line to use an alternate path to the SciTE program, so you can start it using, for example, the portable version instead of installed version for those that don't install AutoIt and/or SciTE4AutoIt3. It will accept a commmand line parameter that points to the SciTE executable. Removed a lot of Global variables by moving the GUI creation and monitoring to the Main function and passing variables from it. I embedded the icon files into the script so that there isn't a separate download of the icon files used here. Saves download time and makes the package smaller. Modification of tools is easier because the icon names, tooltip text, and SciTE command codes are saved in the INI file upon first start up. These can be modified after the script has been run once, even after it's been compiled, by changing the ini file information, you can modify this script to automate it, or you can change it manually in any text editor. The icon files are now using, in just my opinion, better looking icons, after all it's been 7 years and icon files have matured. I have included a file with all of the constants that SciTE uses for its menu commands which comes from the SciTE source file "scite.h", so you can use this file to help you modify the commands that the toolbar works with, by figuring out what each of these values represent in SciTE. The core of the script is pretty much the same, I've just fixed a couple of issues that it had, tweaked a few things, added some new functionality and "prettied" it up a bit.

      If anyone has any suggestions as to improvements, bugs/bugfixes, etc. please let me know.

       
      scitetoolbar.zip
    • Bitpicker
      By Bitpicker
      Not the most eloquent nor efficient, to be sure, but with the following functionality:
      MULTI_BAR Features: ----------------------------------------------------------------
          * Floating MULTIBAR Toolbar with four(4) Docking Positions
          * Drag MULTI bar to Dock at any Edge  position
          * Drag Edge bar to screen center to Float as a MULTI bar
          * FADING EDGE BARS for LEFT, TOP-LEFT, TOP-RIGHT, RIGHT Sides
          * All 4 EDGE BARS and MULTI BAR can exist and execute at one time
          * All Toolbars use common INI file format
          * Any Toolbar  can be displayed by any positional Service EXE
          * All ToolBars have common Controls
              Return to calling BAR [ORIGIN}
              Manual Edit the INI file [INIEDIT]
              Create and place a NEW Toolbar on a button [NEWBAR]
              Search Icon Initiator - search for a Toolbar or a Button Function
              Set AUTO mode for EDGE bar show/fade on cursor or click, [AUTOSW]
              Set AUTO mode for FLOAT bar to close or stay open on button click [AUTOSW]
              Rotate thru 3 button sizes, small, medium and large w/label [B-SIZE]
              EXIT this bar [EXIT]
          * User specifies Number of BUTTONS and Number of ROWS
          * Change Dynamically Number of BUTTONS or ROWS
              via NEWBAR Function Specifying SAME BARNAME with Changed BUTTONS & ROWS
          * Three(3) Button sizes - User can change on demand
          * Shrink to Fit - Will Auto reduce Button size on DOCKING if Bar too long    
          * Buttons can be any File OPEN function, web link, or Open another TOOLBAR_BAR
          * ToolBars can be cascaded down(DRILL DOWN - Button points to another ToolBar) to additional Toolbars
              with Return to previous Toolbar via Origin Function
          * 2 BAR TYPES:
              ACTION(Buttons do TOOLBAR, FILE or URL OPENS)
                  User drops a Link on Button
              DROP(Buttons are Folder Targets)dropped files are sorted to destination
                  MOVE or COPY: FILE, FILE(s) or FOLDERS(DIRs) to Button target
                  Recycle Bin(a Shortcut) is supported as a DROP target for FILE, FILE(s) or FOLDERs
          * Button Context functions
              DELETE the current function - empty the button
              EDIT the TOOLTIP for this Button
              EDIT the LABEL displayed on Large Button
              PLUCK this Button for move to new location on this bar -or-
                  ANY other Bar (in this TOOLBOX)  
              PLACE any PLUCKED Button, or PLACE any NEW TOOL_BAR
              OPEN file location of Button file
      UNZIP the attached to a folder which will be the folder for all toolbar definitions
          and executables. THIS FOLDER IS YOUR TOOLBOX.
          TOOLBOX\MULTIBAR\]README.doc or ]README.pdf provides detail on functions and implementing.
                  
      Appreciate all the SILENT help from the AUTOIT community for this and my many projects. Thanks to all menbers who have provided the best self help book on applied AutoIt.
      Please advise on errors or suggestions. MULTIBAR was developed on Windows 10. Other targets or themes may present errors.For your personal use. Accept no responsibility for its functionality. Enjoy, olbitpicker
      MULTIBAR.zip
    • SteveJM
      By SteveJM
      I have a working program currently driven largely through menu selections. I would like to add a toolbar where most of the tollbar button actions are basically the same as menu items, but quicker to access. I have been wading around in toolbar examples, MSDN pages etc, it's clearly going to be a bit of a slog to get everything right, including tooltips etc. I thought I would start with something simple to prove the principle.
      Using bits from the help file examples I have a small program that successfully displays a toolbar. However, what seemed like the most elegant way to deal with the button commands does not seem to work. My understanding was that a toolbar button fires a WM_COMMAND message, with the command Id set by the second parameter in the call to
      _GUICtrlToolbar_AddButton ( $hWnd, $iID, $iImage)
      so I though it would be a good idea to set this Id to the same value as my menu item Id; then it would run the same task which is what I wanted. This did not work. I am using message loop mode and would like to stick with this because some of my scripts run hardware at the same time as the gui; it is easier if I don't have to worry about code being interrupted with the hardware in an unknown state . So I added a handler for WM_COMMAND, with some cribbed display code to try and see why. The toolbar button defintely fired a WM_COMMAND message and the Id looked the same, so no explanation there.
      I guess the issue is with GUIGetMsg() which may be constructed to ignore all but a limited number of control handles, i.e. those made with the GuiCtrlCreate... commands; this is speculation.
      I would dearly love to find a tidy way to get around this. Having some controls handled in the message loop and some in a WM_COMMAND handler, performing the same task, feels ugly. I would be very grateful for further insight from someone experienced with handling a toolbar. Perhaps I should be trying to fire the menu item. I have attached a code snippet to try and illustrate the issue.
       
       
       
      ToolbarTrial.au3
    • Queener
      By Queener
      This is the info of the interface:
      Window
      Title:    Password Safe
      Class:    #32770
      Control
      Class:    ToolbarWindow32
      Instance:    2
      ClassnameNN:    ToolbarWindow322
      Name:    
      Advanced (Class):    [CLASS:ToolbarWindow32; INSTANCE:2]
       ToolsBar
      1:    32003    Make New Database
      2:    32002    Open Another Database
      3:    32004    Close Database
      4:    32005    Save Database
      5:    0    
      6:    32066    Copy Password to Clipboard
      7:    32068    Copy Username to Clipboard
      8:    32069    Copy Notes to Clipboard
      9:    32065    Clear the clipboard contents
      10:    0    
       
      I wanted to click on 1:    32003    Make New Database. But unfortunately, I'm unable to click on that. Any help is much appreciated. Below are the code I tried:

      $Title = "Password Safe" $Class = "[CLASS:ToolbarWindow32; INSTANCE:2]" WinWaitActive($Title) Sleep(500) Dim $hWnd = WinGetHandle($Title,"") Dim $hToolBar = ControlGetHandle($hWnd, '', $Class) ConsoleWrite($hWnd & @TAB & $hToolBar & @LF) _GUICtrlToolbar_ClickIndex($hToolBar, 32003)
×