Jump to content

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

Simple Winamp Start/Play/Pause Script


  • Please log in to reply
2 replies to this topic
Thracx
  • Members
  • 14 posts
  • Last active: Jul 08 2011 10:29 PM
  • Joined: 12 Mar 2007
You can find tons of AHK scripts out there that control Winamp, many of them advanced and many of them quite simple - this is one of those simple ones. It's part of my main AHK script which I always have running and it does one thing - play Winamp's current Playlist.

In short:If Winamp isn't running, it launches Winamp and hits 'Play'.
If Winamp is running but is currently Paused, it hits 'Play'.
If Winamp is running and is Playing music, it hits 'Pause'.
;	---- ----	Winamp:	Open/Play/Pause	---- ----
SC122::	; Play/Pause (Media Keyboard ScanCode)
DetectHiddenWindows, On	; Tells AHK to search for windows that are minimized/hidden

Target := "ahk_class Winamp v1.x"

IfWinNotExist %Target%
{ ; Try to open Winamp if it's not open
	Run "%ProgramFiles%\Winamp\Winamp.exe"
	;	WinWait ahk_parent	; This caused problems??
	;Return
	WinWait, %Target%
}

IfWinNotExist %Target%
{ ; Check to make sure we were able to open Winamp
	MsgBox Unable to open Winamp
	Return
}
; Winamp is now the last found window - funtions can now implicitly refer to it

; Gets current play status (0=Stopped, 1=Playing, 3=Paused)
SendMessage, 1024, 0, 104	; IsWinampPlaying?
WinampPlayStatus := ErrorLevel

If( WinampPlayStatus == 0 )
{ ; Winamp playback in in a 'Stopped' state
	ControlSend, ahk_parent, x  ; Play
}
else
{
	ControlSend, ahk_parent, c  ; Pause/Unpause
}

return
;	---- ----

I'm relatively new to AHK and will try to post more scripts as I convert them over from a now obsolete version of Girder.
-Thracx

"Man wants to know, and when he ceases to do so, he is no longer a man."
-Fridtjof Nansen

Rhys
  • Members
  • 761 posts
  • Last active: Aug 09 2013 04:53 PM
  • Joined: 17 Apr 2007
I've never used any other automation software - How would you relate AHK to another solution like Girder?

Thracx
  • Members
  • 14 posts
  • Last active: Jul 08 2011 10:29 PM
  • Joined: 12 Mar 2007

I've never used any other automation software - How would you relate AHK to another solution like Girder?

I used to use Girder to create shortcuts - it was very useful in that it could intercept pretty much any input (keyboard mainly for me, although it's designed for media remotes and other fancy input devices), do some processing, and trigger some other action. I had tons of shortcuts setup, some that I'd trigger via a keyboard shortcut and others via my old TV Tuner's remote (the media software that came with it stunk, so I used Girder to use the remote to control a better media player, such as Media Player Classic).

That was a long time ago - Girder is focused on the media center enthusiast and so I never paid for the newer versions (the old v3 was freeware or similar). I've kept using the program for a long time because there wasn't anything that could replace it - until I found AHK, which can do most, if not all, of what Girder can do and I find it to be a lot easier to use (Girder had a clunky GUI and did a lot more than just shortcuts which I don't care much for anymore).

AHK is designed to do exactly what I want 99% of the time - to map a custom keyboard/mouse shortcut to some action, often with some minor processing like this simple Winamp script does. Girder's site doesn't really give a good picture of what it actually is, at least in my mind (which again, is using an old version of it!). The phrase "automation software" is probably a little confusing - AHK is 'automation software', as is any scripting language.

If you happen to want to look into using Girder, be my guest but it seems to be a lot more complex than needed for most tasks that you'll probably want to do. I guess you can say that Girder would be better than AHK in that Girder can have plugins which can allow it to interact with custom hardware (such as a media IR remote, a custom Serial LED or other device, etc). AHK is pretty much limited to what it can 'spy' on from Windows (keyboard, mouse, windowing events, etc), although you could simply write an stand-alone app to serve the function of Girder plugins for AHK. But alas this is all way off-topic, post or PM me a more specific question if you'd like.
-Thracx

"Man wants to know, and when he ceases to do so, he is no longer a man."
-Fridtjof Nansen