AutoHotkey Community

It is currently May 27th, 2012, 3:37 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Is it possible...
PostPosted: July 11th, 2010, 2:36 pm 
Offline

Joined: May 26th, 2009, 2:34 pm
Posts: 40
Location: Queensland, Australia
I'm trying to make an interactive toolbar, much like the ones available for WMM and iTunes, however, I'm stuck.

I don't really know how to reserve space on the taskbar so that the buttons don't appear under it.

I've had a few ideas, with no success yet.

If I could find out the x,y co-ordinates of a taskbar button, I could simply remove the ToolWindow option, and have the gui sit over the button itself.

I got the orginal code to put the Gui on the taskbar from Laszlo's Taskbar Clock/Calender Script. All credits should also go to the sources Laszlo used.

Note: it hasn't been tested on XP, and no, and it isn't simplified, I spose it's what you call proof of concept.

Code:
#NoTrayIcon               
Process Priority,,High
SetWinDelay 0
SetKeyDelay -1
BlockInput Send

if (A_OSVersion in WIN_VISTA) ;os specific stuff
{
    FileInstall,toolbar_button_vista.png,toolbar_button.png,1
   os_button = Button1
   FieldW = 143 ;Width of the Toolbar
   FieldH = 28 ;Height of the Toolbar
} Else if (A_OSVersion in WIN_2003,WIN_XP) {
   FileInstall,toolbar_button_xp.png,toolbar_button.png,1
   os_button = Button2
   FieldW = 159
   FieldH = 27
} Else {
   Msgbox Operating System Not Supported
   ExitApp
}
ControlGetPos, bx,,,, %os_button%, ahk_class Shell_TrayWnd

;----- edit here for best look -----
ToolbarName = Toolbar

FieldX      := bx-FieldW-2 ;Left edge of the Toolbar
FieldY      = 1         ;Top edge of the toolbar

Background   = Black      ;Background
FontColour   = White      ;Font
Font      = Tahoma
FontSize   = 9
FontStyle   =

TxtX      = 20      ;Margin from left
TxtY      = 6         ;Margin from top
TxtW      := FieldW - 4 ;-4 for margins
;----- code starts here -----

VarSetCapacity( memorystatus, 100 )
hw_tray := DllCall( "FindWindowEx", "uint",0, "uint",0, "str","Shell_TrayWnd", "uint",0 )

Menu ToolbarMenu, Add, &Menu, MenuItem1
Menu ToolbarMenu, Add, &Reload, GuiReload
Menu ToolbarMenu, Add, E&xit,  GuiClose
Menu ToolbarMenu, Add, Canc&el,menuCancel

Gui, -Caption ToolWindow ;No title, No taskbar icon
Gui, Add, Picture,x0 y0 h%FieldH% w%FieldW% BackgroundTrans, toolbar_button.png
Gui, Color, %Background%
Gui, font, S%FontSize% %FontStyle% c%FontColour% , %Font%
Gui, Add, Text, x%TxtX% y%TxtY% w%TxtW% vtext BackgroundTrans,Loading...
Gui, Show, x%FieldX% y%FieldY% h%FieldH% w%FieldW%, %ToolbarName%
WinActivate %ToolbarName%
GoSub Dock2TaskBar
WinGet ToolbarID, ID, A      ;ID of Toolbar window

SetTimer ToolbarUpdate, 1000 ;Redraw Toolbar, tooltip
OnMessage(0x200,"GuiHover") ;0x200 = WM_MOUSEMOVE instead of WM_MOUSEHOVER -> MAIN AHK
OnMessage(0x201,"GuiClick") ;0x201 = WM_LBUTTONDOWN -> MAIN AHK

menuCancel:                  ;Do nothing in popup menu
Return

GuiContextMenu:           ;Right click popup menu
   ToolTip                 ;Erase
   Menu ToolbarMenu, Show    ;Show context menu
Return

GuiClose:                 
ExitApp                   

GuiReload:
Reload
Return

GuiClick() {
   msgbox Toolbar has been clicked.
}

MenuItem1:                   
   msgbox Context Menu option has been clicked.
Return

GuiHover() {   ;When the mouse hovers Text
            ;Smoother move than MouseGetPos
   Global ToolbarTip
   IfNotEqual A_Gui,1, Return
   ToolbarTip = 1
   ToolTip Info about toolbar
}

ToolbarUpdate:
   ControlGetPos, bx,,,, %os_button%, ahk_class Shell_TrayWnd
   if (bx-FieldW != FieldX) {
      FieldX := bx-FieldW-2
      WinMove, ahk_id %ToolbarID%,,FieldX,FieldY
   }
   GuiControl 1:,Text,Some toolbar text ;Update toolbar text
   MouseGetPos,,,WinID
   If (WinID = %ToolbarID%){    ;Mouse in Toolbar
      ToolbarTip = 1
      ToolTip Info about toolbar
   } Else If (ToolbarTip){        ;Only clear ours
      ToolbarTip =           ;ToolbarTip: tip removed
      ToolTip
   }
Return

Dock2TaskBar:              ;Active window to be docked to the taskbar, NEEDS hw_tray value
   Process Exist           ;PID -> ErrorLevel
   WinGet hw_gui, ID, ahk_pid %ErrorLevel%
   DllCall( "SetParent", "uint", hw_gui, "uint", hw_tray )
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 12th, 2010, 7:22 am 
Offline

Joined: March 9th, 2007, 2:47 am
Posts: 509
Location: Unknown
http://msdn.microsoft.com/en-us/library/bb776819(VS.85).aspx


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: bobbysoon, Google Feedfetcher, Wicked, Yahoo [Bot] 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