#Include ToolBar.ahk <--- Lightweight ToolBar Work-Around
The code is not commented well, but it creates a "button" that "glows" and shows a tooltip on mouseover.
The Syntax is as follows:
TB_AddButton(Type,IconFile,Label,ToolTip)
Type:
1 = 16x16 icon size Standard
2 = 32x32 icon size Standard
IconFile = The full path of the icon you wish to have on the "button"
Label = the label you want to assign to the "button"
ToolTip = The ToolTip Text shown on Mouseover
I have the following additional "buttons" in the works.
SmallMenuButton
WideMenuButton
Separator
Wide Button
Here it is for now...Comments?....Enjoy....
The Files:
http://www.autohotkey.net/~nkruzan/ToolBar_Files.zip
Download ToolBar_Files.zip
extract files to a directory
Run ToolBarTest.ahk
Updates:
09302006-Added 32x32 Standard buttons
Thanks - biotech
-Changed to use .BMP instead of .PNG if not on WIN_XP
-Added label to UnGlow and remove the tooltip after 1.5
seconds if the mouse is outside the GUI...(this has caused the
button to also unglow if mouse hovering the button has not
moved for 1.5 seconds)
Thanks - Goyyah
ToolBarTest.ahk:
Code:
ButtonPosX=0 ; Starting positions (in window)
ButtonPosY=0
; Add 16x16 icons TYPE 1
TB_AddButton("1","new.ico","T1","Create New File") ; "
TB_AddButton("1","move.ico","T2","Move File")
TB_AddButton("1","delete.ico","T3","Delete File")
TB_AddButton("1","details.ico","T4","File Details")
; Add 32x32 icons TYPE 2
TB_AddButton("2","new.ico","T1","Create New File")
TB_AddButton("2","move.ico","T2","Move File")
TB_AddButton("2","delete.ico","T3","Delete File")
TB_AddButton("2","details.ico","T4","File Details")
;
Gui, +ToolWindow +AlwaysOnTop
Gui, Show,x50 y50, ToolBar Test Script
OnMessage(0x200, "WonderUnderMouse")
Return
;
GuiClose:
ExitApp
;
T1:
MsgBox, Test1
Return
; <--------------
T2:
MsgBox, Test2
Return
; <--------------
T3:
MsgBox, Test3
Return
; <--------------
T4:
MsgBox, Test4
Return
; <--------------
T5:
MsgBox, Test5
Return
;
#Include ToolBar.ahk
ToolBar.ahk:Code:
TB_AddButton(Type,IconFile,Label,ToolTip)
{
Global Type_1_Base, Type_1_Glow
Global Type_2_Base, Type_2_Glow
IfEqual, A_OSVersion, WIN_XP
{
Type_1_Base=ToolbarButtonBase.png
Type_1_Glow=ToolbarButtonGlow.png
Type_2_Base=32x32_Default_Base.png
Type_2_Glow=32x32_Default_Glow.png
}
Else
{
Type_1_Base=ToolbarButtonBase.bmp
Type_1_Glow=ToolbarButtonGlow.bmp
Type_2_Base=32x32_Default_Base.bmp
Type_2_Glow=32x32_Default_Glow.bmp
}
Static TB_AddButton_ButtonNumber
IfGreaterOrEqual, TB_AddButton_ButtonNumber, 1
{
TB_AddButton_ButtonNumber+=1
}
Else
{
TB_AddButton_ButtonNumber:=1
}
q:=TB_AddButton_ButtonNumber
t=1
Loop,
{
IfLess, q, 10
{
Break
}
t:=t+1
q:=q-9
}
;
;
;
Button_ID:=T%t%_B%q%
Transform, Button_ID, deref, T%t%_B%q%
MakeGlobalVarsFor(Button_ID)
%Button_ID%_ToolTip:=ToolTip
%Button_ID%_Label:=Label
%Button_ID%_Type:=Type
IfEqual, Type, 1 ; 16x16 icon
{
H := "26"
W := "24"
Gap := "3"
StartX := "5"
Starty := "5"
Global ButtonPosY
Global ButtonPosX
IfEqual, ButtonPosX, 0
{
ButtonPosX := StartX
}
Else
{
ButtonPosX := ButtonPosX + W + (Gap*2)
}
IfEqual, ButtonPosY, 0
{
ButtonPosY := StartY
}
Else
{
}
IconPosX :=ButtonPosX + 4 ; %
IconPosY :=ButtonPosY + 5 ; %
Gui, Add, Picture, x%IconPosX% y%IconPosY% altsubmit w16 h16 gTB_ButtonClick, %Button_ID%_1
Gui, Add, Picture, x%ButtonPosX% y%ButtonPosY% %TB_ButtonSize% altsubmit gTB_ButtonClick 0x4000000 , %Button_ID%_2
Sleep, 1
GuiControl,, %Button_ID%_1, %IconFile%
Transform, Type, deref, % %Button_ID%_Type ; %
GuiControl,, %Button_ID%_2, % Type_%Type%_Base ; %
ButtonPosX := ButtonPosX
}
IfEqual, Type, 2 ; 32x32 Icon
{
H := "40"
W := "40"
Gap := "5"
StartX := "5"
Starty := "5"
Global ButtonPosY
Global ButtonPosX
TB_ButtonSize:= "h" . H . " " . "w" . W
IfEqual, ButtonPosX, 0
{
ButtonPosX := StartX
}
Else
{
ButtonPosX := ButtonPosX + W + (Gap*2)
}
IfEqual, ButtonPosY, 0
{
ButtonPosY := StartY
}
Else
{
}
IconPosX :=ButtonPosX + 4 ; %
IconPosY :=ButtonPosY + 5 ; %
Gui, Add, Picture, x%IconPosX% y%IconPosY% altsubmit w32 h32 gTB_ButtonClick, %Button_ID%_1
Gui, Add, Picture, x%ButtonPosX% y%ButtonPosY% %TB_ButtonSize% altsubmit gTB_ButtonClick 0x4000000 , %Button_ID%_2
GuiControl,, %Button_ID%_1, %IconFile%
GuiControl,, %Button_ID%_2, 32x32_Default_Base.png
ButtonPosX := ButtonPosX
}
}
;
MakeGlobalVarsFor(Button_ID)
{
Global
%Button_ID%_Label:=0
%Button_ID%_ToolTip:=0
%Button_ID%_Type:=0
}
;
WonderUnderMouse()
{
Static ButtonName
Global CurrControl
Global PrevControl
PrevControl:=CurrControl
CurrControl := A_GuiControl
StringLeft, PrevControl, PrevControl, 5
StringLeft, CurrControl, CurrControl, 5
IfNotEqual, PrevControl, %CurrControl%
{
Transform, Type2, deref, % %PrevControl%_Type ; %
GuiControl,, %PrevControl%_2, % Type_%Type2%_Base ; %
}
If (CurrControl <> PrevControl)
{
Transform, Type2, deref, % %CurrControl%_Type ; %
GuiControl,, %CurrControl%_2, % Type_%Type2%_Glow ; %
}
Else
{
StringLeft, ButtonName, CurrControl, 5
ToolTip, % %ButtonName%_ToolTip ; %
Global LastActiveButton
LastActiveButton:=ButtonName
SetTimer, KillTT, 1500
}
}
KillTT:
Transform, Type3, deref, % %LastActiveButton%_Type ; %
GuiControl,, %LastActiveButton%_2, % Type_%Type3%_Base ; %
Tooltip
return
TB_ButtonClick:
CurrControl := A_GuiControl
StringLeft, ButtonName, CurrControl, 5
Gosub, % %ButtonName%_Label ; %
Return
EDIT: Updated Files and Zip for easier usage.092506-101500-njk
EDIT: Added zip with .BMP files for compatability
EDIT: Update