AutoHotkey Community

It is currently May 27th, 2012, 7:45 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: September 26th, 2006, 2:48 pm 
Offline

Joined: June 26th, 2006, 6:14 pm
Posts: 1379
Location: USA
#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.
Image
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 September 30th, 2006, 6:34 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2006, 4:16 pm 
Offline

Joined: June 26th, 2006, 6:14 pm
Posts: 1379
Location: USA
Feedback....Please..... :roll:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 27th, 2006, 5:50 pm 
Offline

Joined: June 26th, 2006, 6:14 pm
Posts: 1379
Location: USA
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 27th, 2006, 6:14 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
ahklerner wrote:
100 people read this and not one reply......Awesome..


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

Nice work friend! :)

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

Regards, :)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 27th, 2006, 6:45 pm 
Offline

Joined: June 26th, 2006, 6:14 pm
Posts: 1379
Location: USA
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 September 30th, 2006, 6:37 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 29th, 2006, 4:33 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 30th, 2006, 12:42 am 
Offline

Joined: February 24th, 2006, 12:56 am
Posts: 172
32x32 icons would be great


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 30th, 2006, 9:44 am 
Offline

Joined: January 7th, 2006, 1:38 pm
Posts: 47
Location: Oslo, Norway
wow, This is great. I've been hoping to see something like this, for launching context sensitive AHK-scripts for instance! Thanks for sharing!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 18th, 2007, 12:35 pm 
Offline

Joined: November 9th, 2007, 7:48 pm
Posts: 16
Looks like object dock, but ill prefere this one.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2007, 12:33 pm 
Offline

Joined: July 20th, 2007, 10:23 am
Posts: 257
Location: Paris, France
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 :)

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

Thank you


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2007, 12:37 pm 
Offline

Joined: June 26th, 2006, 6:14 pm
Posts: 1379
Location: USA
This is not needed anymore.....see lexikos' post here:
http://www.autohotkey.com/forum/viewtopic.php?t=25700

_________________
Image
ʞɔпɟ əɥʇ ʇɐɥʍ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 30th, 2009, 12:26 pm 
gj! iam using it :)


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Cristi®, nothing and 12 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group