Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

titlebar clock/remote control/launcher script


  • Please log in to reply
6 replies to this topic
Serenity
  • Members
  • 1271 posts
  • Last active:
  • Joined: 07 Nov 2004
Posted Image

Above is a screenshot of a script I am working on which displays the system time in the title bar area, along with remote buttons for Winamp (though I'm using fb2k now. ;)). More icons can be added to launch programs, commands (FileRecycleEmpty for example) scripts etc. I'm hoping to implement a context menu of sorts at some point.

Tip- if you link an icon to ShortPopUp in the script the menu will appear near the icon clicked. :)

Get the icons here.

Changelog:
Added right-click context menu. (currently works with ahk_class not screen coords, so not perfect.)
Replaced Gui, Destroy approach with SetTimer (thanks toralf!)
Improved Date/Time section to toggle show/hide display properties view via tray icon.

Heres the script so far (you'll need AutoHotkey v1.0.26+ for this script to work):

; titlebar clock/remote control/launcher script by Serenity

; specify the path to winamp here:
path = d:\winamp\winamp.exe

#singleinstance 

;______________________
; tray menu here

menu, tray, icon, Clock.ico, 1
menu, tray, tip, titlebar clock

Menu, Tray, NoStandard ; only use this menu
Menu, Tray, Click, 1  ; Remove this line if you prefer double-click vs. single-click.

Menu, Tray, Add, &Date/Time, Datetime
Menu, Tray, Default, &Date/Time

Menu, Tray, Add ; separator
Menu, Tray, Add, &Reload, Reload
Menu, Tray, Add, E&xit, Exit


;______________________
; gui ctx menu here

Menu, ctx, Add, &1, entry1
Menu, ctx, Add, &2, entry2
Menu, ctx, Add, &3, entry3
Menu, ctx, Add, &4, entry4
Menu, ctx, color, FFFFFF


;______________________
; gui here

FormatTime, TimeString, , hh:mm - ddd, dd MMM ; put the time and date into the window title

Gui, +ToolWindow +AlwaysOnTop -SysMenu
Gui, -Caption ; use this to remove the tooltip top!
Gui, Color, CCCCCC

Gui, Add, Picture, gwinamp x3 y0, h_winamp.ico
Gui, Add, Picture, gprev x+3 y0, h_prev.ico
Gui, Add, Picture, gplay x+3 y0, h_play.ico
Gui, Add, Picture, gpause x+3 y0, h_pause.ico
Gui, Add, Picture, gstop x+3 y0, h_stop.ico
Gui, Add, Picture, gnext x+3 y0, h_next.ico

Gui, Font, cFFFFFF s6 wbold, terminal
Gui, Add, Text, vTxtCurrentTime  x+10 y5, %TimeString% 

Gui, Show, AutoSize NoActivate xcenter y0 h18 w240, %TimeString% 
; NoActivate avoids deactivating the currently active window.
; Autosize prevents longer time formats from being clipped.

WinSet, TransColor, CCCCCC 255, ahk_class AutoHotkeyGUI
SetTimer, AdjustTime, 60000
return

AdjustTime:
FormatTime, TimeString, , hh:mm - ddd, dd MMM ; put the time and date into the window title
GuiControl, , TxtCurrentTime, %TimeString%
Gui, Show, NoActivate h18 w240, %TimeString%
return


;______________________
; icons functions

winamp:
postmessage, 0x111, 40258,,, ahk_class Winamp v1.x ; toggle main window
return

prev:
PostMessage, 0x111, 40044,,, ahk_class Winamp v1.x
return

play:
PostMessage, 0x111, 40045,,, ahk_class Winamp v1.x
return

pause:
PostMessage, 0x111, 40046,,, ahk_class Winamp v1.x
return

stop:
PostMessage, 0x111, 40047,,, ahk_class Winamp v1.x
return

next:
PostMessage, 0x111, 40048,,, ahk_class Winamp v1.x
return


;______________________
; ctx menu entries

entry1:
entry2:
entry3:
entry4:
SoundPlay, blip.wav
return


;______________________
; ctx menu mouse handler

RButton::
MouseGetPos,,, MouseWin
WinGetClass, MouseClass, ahk_id %MouseWin%
if MouseClass in AutoHotkeyGUI  ; Mouse is in gui 
{
  Menu, ctx, show
  return
}
; else do normal right-click
MouseClick, right,,,,, D
KeyWait, RButton ; Wait for the user to physically release the button.
MouseClick, right,,,,, U  ; Release it logically to match.
return


;______________________
; tray menu entries

Datetime:
IfWinExist, Date/Time Properties
WinClose
else
run, C:/WINNT/system32/timedate.cpl
return

Reload:
reload
return

Exit:
exitapp


;______________________
; hotkeys

~^R::reload

"Anything worth doing is worth doing slowly." - Mae West
Posted Image

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
cool idea Serenity! ... it looks nice too!
i'd suggest to keep the icon in tray.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
Hi Serenity,

I would suggest to not always destroy the window, just change the title bar with a timer. Suggestion:
path = d:\winamp\winamp.exe 
#singleinstance 
#NoTrayIcon 

Gui, +ToolWindow +AlwaysOnTop -SysMenu 
Gui, -Caption ; use this to remove the tooltip top! 
Gui, Color, CCCCCC 

Gui, Add, Picture, gwinamp x3 y0, h_winamp.ico 
Gui, Add, Picture, gprev x+3 y0, h_prev.ico 
Gui, Add, Picture, gplay x+3 y0, h_play.ico 
Gui, Add, Picture, gpause x+3 y0, h_pause.ico 
Gui, Add, Picture, gstop x+3 y0, h_stop.ico 
Gui, Add, Picture, gnext x+3 y0, h_next.ico 

Gui, Font, cFFFFFF s6 wbold, terminal 
FormatTime, TimeString, , hh:mm - ddd, dd MMM ; put the time and date into the window title 
Gui, Show, NoActivate xcenter y0 h18 w240, %TimeString% ; NoActivate avoids deactivating the currently active window. 

WinSet, TransColor, CCCCCC 255, ahk_class AutoHotkeyGUI 
SetTimer,AdjustTime,60000
return

AdjustTime:
FormatTime, TimeString, , hh:mm - ddd, dd MMM ; put the time and date into the window title 
Gui, Show,NoActivate h18 w240, %TimeString%
return

;______________________ 
; icons functions 

winamp: 
prev: 
play: 
pause: 
stop: 
next: 
return

*NOT tested*
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

Serenity
  • Members
  • 1271 posts
  • Last active:
  • Joined: 07 Nov 2004
Thanks Rajat. :) The tray icon menu could be useful as a way to launch things too.

toralf, thanks. The script works, though it only updates the titlebar and not the text display in the gui. Ideally there'd be a way to redraw the gui faster so it doesn't flicker. I had already tried WinSet, Redraw and this didn't work, and using WinHide, WinShow flickers more than the Gui, Destroy approach.
"Anything worth doing is worth doing slowly." - Mae West
Posted Image

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
If you want to update the text too, just add this to the auto exex
Gui, Add, Text, vTxtCurrentTime x+10 y5, %TimeString%
[I have only added the variable]

And into the AdjustTime subroutine after FormatTime this:
GuiControl,,TxtCurrentTime,%TimeString%
This should update the text too.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

Serenity
  • Members
  • 1271 posts
  • Last active:
  • Joined: 07 Nov 2004
Thanks toralf, I've updated the script to incorporate this. :)
"Anything worth doing is worth doing slowly." - Mae West
Posted Image

  • Guests
  • Last active:
  • Joined: --
Hi,

i´d like to use this script only to show the time but is it possible to put the time and the date into the titlebar of firefox and windows explorer?
Because the script of Serenity only makes a bar or a transparent windows on the top of screen.


thx a lot

tetam