Whilst theres several apps available that do the same thing, I wrote this script mainly to demonstrate that this can be done with AutoHotkey.
Running the main script places six icons in your systray like so:
Each icon has its own function (play, pause, stop etc) and changes to red temporarily to confirm the icon has been clicked.
You can download all the scripts and icons needed from
here.
Some issues:
* In order for the main script to close all other icons along with itself you will need to compile each child script, or scriptlets as I like to think of them.
* Currently, clicking on the "Winamp" icon only activates Winamp. If Winamp is not running it will open it. I would like for the main "Winamp" icon to toggle all Winamp windows (main window, including playlist and equaliser windows) between active/minimized states.
Main script:
Code:
; this script enables winamp to be controlled via icons in the systray
; specify the path to winamp here:
path = d:\winamp\winamp.exe
#Persistent ; keep program running
#SingleInstance force
Run, prev.ahk
sleep, 100
Run, play.ahk
sleep, 100
Run, pause.ahk
sleep, 100
Run, stop.ahk
sleep, 100
Run, next.ahk
sleep, 100
menu, tray, icon, winamp.ico, 1
menu, tray, tip, winamp systray
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, &Winamp, Winamp
Menu, Tray, Default, &Winamp
Menu, Tray, Add ; separator
Menu, Tray, Add, (&1) Play, Play
Menu, Tray, Add, (&2) Pause, Pause
Menu, Tray, Add, (&3) Stop, Stop
Menu, Tray, Add ; separator
Menu, Tray, Add, (&4) Prev, Prev
Menu, Tray, Add, (&5) Next, Next
Menu, Tray, Add ; separator
Menu, Tray, Add, &Reload, Reload
Menu, Tray, Add, &Suspend, Suspend
Menu, Tray, Add, E&xit, Exit
return
; PostMessage, Msg [, wParam, lParam, Control, WinTitle, WinText, ExcludeTitle, ExcludeText]
Winamp:
IfWinNotExist, ahk_class Winamp v1.x
{
Run, %path%
WinActivate, ahk_class Winamp v1.x
return
}
IfWinNotActive, ahk_class Winamp v1.x
{
WinActivate, ahk_class Winamp v1.x
return
}
WinMinimize, 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
Prev:
PostMessage, 0x111, 40044,,, ahk_class Winamp v1.x
return
Next:
PostMessage, 0x111, 40048,,, ahk_class Winamp v1.x
return
Reload:
Reload
return
Suspend:
Suspend
return
Exit:
Process, Close, prev.exe
Process, Close, play.exe
Process, Close, pause.exe
Process, Close, stop.exe
Process, Close, next.exe
Exitapp
Scriptlets:Code:
; prev.ahk
#Persistent
#SingleInstance force
Menu, Tray, NoStandard ; only use this menu
Menu, Tray, Click, 1 ; Remove this line if you prefer double-click vs. single-click.
menu, tray, tip, previous track
menu, tray, icon, prev.ico, 1
Menu, Tray, Add, Previous, Previous
Menu, Tray, Default, Previous
Menu, Tray, Add, Exit, Exit
return
Previous:
PostMessage, 0x111, 40044,,, ahk_class Winamp v1.x
PostMessage, 0x111, 40047,,, ahk_class Winamp v1.x ; remove this line if you prefer it to skip and play automatically
GoSub, Icon
return
Exit:
ExitApp
Icon:
menu, tray, icon, red_prev.ico, 1
sleep, 200
menu, tray, icon, prev.ico, 1
Code:
; play.ahk
#Persistent
#SingleInstance force
Menu, Tray, NoStandard ; only use this menu
Menu, Tray, Click, 1 ; Remove this line if you prefer double-click vs. single-click.
menu, tray, tip, play track
menu, tray, icon, play.ico, 1
Menu, Tray, Add, Play, Play
Menu, Tray, Default, Play
Menu, Tray, Add, Exit, Exit
return
Play:
PostMessage, 0x111, 40045,,, ahk_class Winamp v1.x
GoSub, Icon
return
Exit:
ExitApp
Icon:
menu, tray, icon, red_play.ico, 1
sleep, 200
menu, tray, icon, play.ico, 1
Code:
; pause.ahk
#Persistent
#SingleInstance force
Menu, Tray, NoStandard ; only use this menu
Menu, Tray, Click, 1 ; Remove this line if you prefer double-click vs. single-click.
menu, tray, tip, pause track
menu, tray, icon, pause.ico, 1
Menu, Tray, Add, Pause, Pause
Menu, Tray, Default, Pause
Menu, Tray, Add, Exit, Exit
return
Pause:
PostMessage, 0x111, 40046,,, ahk_class Winamp v1.x
GoSub, Icon
return
Exit:
ExitApp
Icon:
menu, tray, icon, red_pause.ico, 1
sleep, 200
menu, tray, icon, pause.ico, 1
Code:
; stop.ahk
#Persistent
#SingleInstance force
Menu, Tray, NoStandard ; only use this menu
Menu, Tray, Click, 1 ; Remove this line if you prefer double-click vs. single-click.
menu, tray, tip, stop track
menu, tray, icon, stop.ico, 1
Menu, Tray, Add, Stop, Stop
Menu, Tray, Default, Stop
Menu, Tray, Add, Exit, Exit
return
Stop:
PostMessage, 0x111, 40047,,, ahk_class Winamp v1.x
GoSub, Icon
return
Exit:
ExitApp
Icon:
menu, tray, icon, red_stop.ico, 1
sleep, 200
menu, tray, icon, stop.ico, 1
Code:
; next.ahk
#Persistent
#SingleInstance force
Menu, Tray, NoStandard ; only use this menu
Menu, Tray, Click, 1 ; Remove this line if you prefer double-click vs. single-click.
menu, tray, tip, next track
menu, tray, icon, next.ico, 1
Menu, Tray, Add, Next, Next
Menu, Tray, Default, Next
Menu, Tray, Add, Exit, Exit
return
Next:
PostMessage, 0x111, 40048,,, ahk_class Winamp v1.x
PostMessage, 0x111, 40047,,, ahk_class Winamp v1.x ; remove this line if you prefer it to skip and play automatically
GoSub, Icon
return
Exit:
ExitApp
Icon:
menu, tray, icon, red_next.ico, 1
sleep, 200
menu, tray, icon, next.ico, 1