AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

#Include ToolBar.ahk <--- Updated 09/30/2006 32x32 icons

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
ahklerner



Joined: 26 Jun 2006
Posts: 1381
Location: USA

PostPosted: Tue Sep 26, 2006 1:48 pm    Post subject: #Include ToolBar.ahk <--- Updated 09/30/2006 32x32 icons Reply with quote

#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


Last edited by ahklerner on Sat Sep 30, 2006 5:34 pm; edited 2 times in total
Back to top
View user's profile Send private message
ahklerner



Joined: 26 Jun 2006
Posts: 1381
Location: USA

PostPosted: Tue Sep 26, 2006 3:16 pm    Post subject: Reply with quote

Feedback....Please..... Rolling Eyes
Back to top
View user's profile Send private message
ahklerner



Joined: 26 Jun 2006
Posts: 1381
Location: USA

PostPosted: Wed Sep 27, 2006 4:50 pm    Post subject: Reply with quote

No one even try?......

100 people read this and not one reply......Awesome..

Oh well, a little bit more about it. it can easily be modified to show in a specific position on the screen. It runs the glabel stated at the Call of TB_AddButton when the button is pressed.

All that is needed is to create the label in your script and include the function(s).....

The first script I above was just a simple demonstration......

I guess only I see the useability of this....whatever.....

If anyone would like to take the time however, to give me ideas on how to streamline it. I would be much obliged.
thanks-Nick
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Wed Sep 27, 2006 5:14 pm    Post subject: Reply with quote

ahklerner wrote:
100 people read this and not one reply......Awesome..


I was not in that 100 ! 108 to be precise Very Happy
Anyways! I took a quick glance .. Have not studied the code in full!

Nice work friend! Smile

What about that glow? I do not get one .. .PNG files are not supported in Windows 2000 I guess!

And one more thing .. if I move the cursor away from the toolbar window ( that is very quickly ) the tooltip does not hide..

Keep up the good work .. Smile

Regards, Smile
_________________
URLGet - Internet Explorer based Downloader
Back to top
View user's profile Send private message Send e-mail
ahklerner



Joined: 26 Jun 2006
Posts: 1381
Location: USA

PostPosted: Wed Sep 27, 2006 5:45 pm    Post subject: Reply with quote

Quote:
What about that glow? I do not get one .. .PNG files are not supported in Windows 2000 I guess!

Added .zip with BMP images instead...Above

Quote:
Nice work friend!

Thank you very much..

Quote:
the tooltip does not hide..

Fixed Now -09/30/2006


Last edited by ahklerner on Sat Sep 30, 2006 5:37 pm; edited 1 time in total
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10716

PostPosted: Fri Sep 29, 2006 3:33 am    Post subject: Reply with quote

I just tried it. This is a very professional-looking toolbar, especially the mouse-over highlighting effect! Also, I know the nice function-interface you provided will be appreciated by many since it makes it so easy to create the toolbars by adding the buttons one by one.

Thanks for sharing it.
Back to top
View user's profile Send private message Send e-mail
biotech



Joined: 23 Feb 2006
Posts: 172

PostPosted: Fri Sep 29, 2006 11:42 pm    Post subject: Reply with quote

32x32 icons would be great
Back to top
View user's profile Send private message Visit poster's website
TucknDar



Joined: 07 Jan 2006
Posts: 47
Location: Oslo, Norway

PostPosted: Sat Sep 30, 2006 8:44 am    Post subject: Reply with quote

wow, This is great. I've been hoping to see something like this, for launching context sensitive AHK-scripts for instance! Thanks for sharing!
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
stekkie



Joined: 09 Nov 2007
Posts: 16

PostPosted: Sun Nov 18, 2007 11:35 am    Post subject: Reply with quote

Looks like object dock, but ill prefere this one.
Back to top
View user's profile Send private message
Andreone



Joined: 20 Jul 2007
Posts: 257
Location: Paris, France

PostPosted: Mon Nov 19, 2007 11:33 am    Post subject: Reply with quote

Thanks for this nice scriptlet. I already know where I'll use it.
However, it looks more to me as a "fancy button" script than a toolbar script Smile

Can you add a comment to indicate which message is 0x200 ?
Code:
OnMessage(0x200, "WonderUnderMouse") 

Thank you
Back to top
View user's profile Send private message
ahklerner



Joined: 26 Jun 2006
Posts: 1381
Location: USA

PostPosted: Mon Nov 19, 2007 11:37 am    Post subject: Reply with quote

This is not needed anymore.....see lexikos' post here:
http://www.autohotkey.com/forum/viewtopic.php?t=25700
_________________

ʞɔпɟ əɥʇ ʇɐɥʍ
Back to top
View user's profile Send private message
_ease
Guest





PostPosted: Wed Sep 30, 2009 11:26 am    Post subject: Reply with quote

gj! iam using it Smile
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group