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.