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 

Make space pause Media Player

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
slekvak
Guest





PostPosted: Sun May 11, 2008 4:39 pm    Post subject: Make space pause Media Player Reply with quote

Hi,

I'm trying to make a script which make pressing space pause Windows Media Player. I have made this:

Space::
IfWinActive, Windows Media Player
{
send {Media_Play_Pause}
}
else {
send {Space}
}
return

But I can't get it to work. It works when media player is active (it pauses it), but the "else"-part doesnt work. I get this error: 71 hotkeys have been received in the last 711ms.

Why doesn't it work?

Thanks
Back to top
Superfraggle



Joined: 02 Nov 2004
Posts: 753
Location: London, UK

PostPosted: Sun May 11, 2008 4:43 pm    Post subject: Reply with quote

Code:
#IfWinActive, Windows Media Player
 Space::Send,{Media_Play_Pause}

_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle
Back to top
View user's profile Send private message MSN Messenger
Slekvak
Guest





PostPosted: Sun May 11, 2008 4:50 pm    Post subject: Reply with quote

That did the trick. Thanks for the quick reply!
Back to top
Slekvak
Guest





PostPosted: Sun May 11, 2008 4:52 pm    Post subject: Reply with quote

Doesn't seem to work in fullscreen mode though. Any ideas?
Back to top
Superfraggle



Joined: 02 Nov 2004
Posts: 753
Location: London, UK

PostPosted: Sun May 11, 2008 4:57 pm    Post subject: Reply with quote

In full screen mode my guess is the window title changes.



Code:

GroupAdd,mplayer,Windows Media Player
GroupAdd,mplayer,ahk_class WMPTransition

#IfWinActive,ahk_group mplayer
 Space::Send,{Media_Play_Pause}


This should now work.
_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle
Back to top
View user's profile Send private message MSN Messenger
Slekvak
Guest





PostPosted: Sun May 11, 2008 5:09 pm    Post subject: Reply with quote

It worked when I had a fullscreen web-player, but now it doesn't work when I play a file (from my drive) in either fullscreen or windowed mode.
Back to top
Superfraggle



Joined: 02 Nov 2004
Posts: 753
Location: London, UK

PostPosted: Sun May 11, 2008 5:12 pm    Post subject: Reply with quote

Check the window titles match, use the window spy to ensure the window titles are the same.
_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle
Back to top
View user's profile Send private message MSN Messenger
Slekvak
Guest





PostPosted: Sun May 11, 2008 5:17 pm    Post subject: Reply with quote

Seems to work now.. Thank you!
Back to top
Slekvak
Guest





PostPosted: Sun May 11, 2008 10:45 pm    Post subject: Reply with quote

When I put the code above my other hotkeys (like #f::run firefox), those don't work. When I put it below them, that one don't work. Any idea why that is?

Code:
GroupAdd,mplayer,Windows Media Player
GroupAdd,mplayer,ahk_class WMPTransition

#IfWinActive,ahk_group mplayer
 Space::Send,{Media_Play_Pause}

#f::run firefox
#b::run bitche
Back to top
Superfraggle



Joined: 02 Nov 2004
Posts: 753
Location: London, UK

PostPosted: Sun May 11, 2008 11:09 pm    Post subject: Reply with quote

The #Ifwinactive specifies that all hotkeys from this point on should only work in the sepecified window.

If you put that as the first few lines then all hotkeys will only work in Media player. Either place the hotkeys below all the rest. Or Use

Code:
#Ifwinactive, ; Blank to turn off any limitations.

_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle
Back to top
View user's profile Send private message MSN Messenger
Slekvak
Guest





PostPosted: Sun May 11, 2008 11:28 pm    Post subject: Reply with quote

I'm sorry, but I can't get it to work.

I can't put the media player code at the bottom. Then it doesn't work. If i remove "vahk_group mplayer" from the IfWinActive line as you said, space doesn't work at all when other apps are in focus. What am I missing or not understand?

Thanks
Back to top
Superfraggle



Joined: 02 Nov 2004
Posts: 753
Location: London, UK

PostPosted: Mon May 12, 2008 1:01 am    Post subject: Reply with quote

Your code should be as follows

Code:
GroupAdd,mplayer,Windows Media Player
GroupAdd,mplayer,ahk_class WMPTransition

#IfWinActive,ahk_group mplayer ; All hotkeys from this point only work when media player is active
 Space::Send,{Media_Play_Pause}
#Ifwinactive, ; All hotkeys from now on work in any window.

; All other hotkeys

_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help 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