 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Serenity
Joined: 07 Nov 2004 Posts: 1276
|
Posted: Thu Feb 10, 2005 2:16 am Post subject: Control Winamp via systray icons |
|
|
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 |
_________________ "Anything worth doing is worth doing slowly." - Mae West
 |
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3004 Location: Minnesota
|
Posted: Thu Feb 10, 2005 2:23 am Post subject: |
|
|
I like it... but I won't actually use it because I viciously guard my screen real estate, especially in the tray.
One thing that might incline me to give it a try, though, is if it were made toolbar-capable. This can be done easily my making scripts that perform their function when they're run, then immediately exit. In this way, you could add shortcuts to these scripts to a folder, then add that folder to the taskbar as a toolbar. Voila! Instant Winamp controls! You can even customize the icons, since they're shortcuts.
You up to the challenge?  |
|
| Back to top |
|
 |
Serenity
Joined: 07 Nov 2004 Posts: 1276
|
Posted: Thu Feb 10, 2005 2:32 am Post subject: |
|
|
lol! Well I don't use it either as I already have Winampbar.
The toolbar idea is nice, but it means running something like ShortPopUp from the quicklaunch to get at the menu items, which means the functions are more than one click away. I prefer the idea of a small always-on-top toolwindow. For example, QuickTask puts the taskbar into a floating always-on-top tool window. To recreate something like that with AutoHotkey would be really cool.  _________________ "Anything worth doing is worth doing slowly." - Mae West
 |
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3004 Location: Minnesota
|
Posted: Thu Feb 10, 2005 3:17 am Post subject: |
|
|
No, you don't need an app... on XP (and I'm pretty sure on older ones too, but I don't have one to test on), you can simply right-click the taskbar, go to the Toolbars submenu, then click New Toolbar.... This shows a dialog where you can select a folder. The contents of the folder will be displayed as quicklaunch-style icons.
Btw, VP's awesome. I've been wanting to sign up for some time, as their site is one of the best, but I'm the worst procrastinator the world has ever seen. (Well, fine, not the world, but at least this forum )
As for recreating a QuickTask-esque toolbar with AHK, I think it sounds possible, but it wouldn't be pretty. You could probably even use the existing icons you've made. I'll add it to my "I'll get around to it sometime" list. (This list is also my "boredom" list, and as I have disgustingly large amounts of free time, this list usually runs down pretty fast) |
|
| Back to top |
|
 |
Serenity
Joined: 07 Nov 2004 Posts: 1276
|
Posted: Thu Feb 10, 2005 4:40 am Post subject: |
|
|
Using the toolbar is good, I prefer using ShortPopUp in the quicklaunch for the control the .ini file offers.
I compiled stripped down versions the systray scriptlets (each .exe turns out to be 178kb!) so that I could specify my own icons in the menus.
The scriptlets for the toolbar/quicklaunch version:
| Code: | ; prev.ahk
#NoTrayIcon
#SingleInstance force
PostMessage, 0x111, 40044,,, ahk_class Winamp v1.x |
| Code: | ; play.ahk
#NoTrayIcon
#SingleInstance force
PostMessage, 0x111, 40045,,, ahk_class Winamp v1.x |
| Code: | ; pause.ahk
#NoTrayIcon
#SingleInstance force
PostMessage, 0x111, 40046,,, ahk_class Winamp v1.x |
| Code: | ; stop.ahk
#NoTrayIcon
#SingleInstance force
PostMessage, 0x111, 40047,,, ahk_class Winamp v1.x |
| Code: | ; next.ahk
#NoTrayIcon
#SingleInstance force
PostMessage, 0x111, 40048,,, ahk_class Winamp v1.x |
_________________ "Anything worth doing is worth doing slowly." - Mae West
 |
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3004 Location: Minnesota
|
Posted: Thu Feb 10, 2005 4:52 am Post subject: |
|
|
| Heh... you don't really have to compile, you know. All you have to do is make a shortcut to it, and then you can set the icon. Unless you're worried about that annoying little arrow, in which case I'd suggest MenuApp (IMHO a really good custom menu program, which I think has an option to turn off those darn arrows). |
|
| Back to top |
|
 |
Serenity
Joined: 07 Nov 2004 Posts: 1276
|
Posted: Thu Feb 10, 2005 5:04 am Post subject: |
|
|
I totally forgot you could use shortcuts! (No problem with the little arrow here, disabled that in the registry.) Now all we need is to be able to show icons for menu entries in menus made with AutoHotkey.  _________________ "Anything worth doing is worth doing slowly." - Mae West
 |
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3004 Location: Minnesota
|
Posted: Thu Feb 10, 2005 6:43 am Post subject: |
|
|
That is already planned, suggested by yours truly. You won't see it in the planned features list, though, because it's still on the "informal" list. |
|
| Back to top |
|
 |
Pallie
Joined: 05 Jul 2004 Posts: 57 Location: London
|
Posted: Wed Feb 23, 2005 11:21 pm Post subject: |
|
|
Serenity
I love it. There is no substitute for having you own version of existing programs so that you can build in your own functions. I plan to use this as a basis for controlling WINAMP remotely over the LAN.
Mike |
|
| Back to top |
|
 |
Serenity
Joined: 07 Nov 2004 Posts: 1276
|
Posted: Thu Feb 24, 2005 1:00 am Post subject: |
|
|
Thanks Mike.  _________________ "Anything worth doing is worth doing slowly." - Mae West
 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|