AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Simple Winamp Start/Play/Pause Script

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Thracx



Joined: 12 Mar 2007
Posts: 10
Location: Northern VA

PostPosted: Tue Feb 19, 2008 2:15 am    Post subject: Simple Winamp Start/Play/Pause Script Reply with quote

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'.
Code:
;   ---- ----   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


Last edited by Thracx on Tue Feb 19, 2008 3:27 am; edited 1 time in total
Back to top
View user's profile Send private message
Rhys



Joined: 17 Apr 2007
Posts: 736
Location: Florida

PostPosted: Tue Feb 19, 2008 2:33 am    Post subject: Reply with quote

I've never used any other automation software - How would you relate AHK to another solution like Girder?
_________________
[Join IRC!]

http://www.codeforcure.org/
Back to top
View user's profile Send private message
Thracx



Joined: 12 Mar 2007
Posts: 10
Location: Northern VA

PostPosted: Tue Feb 19, 2008 3:27 am    Post subject: Reply with quote

Rhys wrote:
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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group