Jump to content


Make space pause Media Player


  • Please log in to reply
18 replies to this topic

#1 slekvak

slekvak
  • Guests

Posted 11 May 2008 - 03:39 PM

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

#2 Superfraggle

Superfraggle
  • Members
  • 1019 posts

Posted 11 May 2008 - 03:43 PM

#IfWinActive, Windows Media Player

 Space::Send,{Media_Play_Pause}



#3 Slekvak

Slekvak
  • Guests

Posted 11 May 2008 - 03:50 PM

That did the trick. Thanks for the quick reply!

#4 Slekvak

Slekvak
  • Guests

Posted 11 May 2008 - 03:52 PM

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

#5 Superfraggle

Superfraggle
  • Members
  • 1019 posts

Posted 11 May 2008 - 03:57 PM

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



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

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

This should now work.

#6 Slekvak

Slekvak
  • Guests

Posted 11 May 2008 - 04:09 PM

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.

#7 Superfraggle

Superfraggle
  • Members
  • 1019 posts

Posted 11 May 2008 - 04:12 PM

Check the window titles match, use the window spy to ensure the window titles are the same.

#8 Slekvak

Slekvak
  • Guests

Posted 11 May 2008 - 04:17 PM

Seems to work now.. Thank you!

#9 Slekvak

Slekvak
  • Guests

Posted 11 May 2008 - 09:45 PM

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?

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


#10 Superfraggle

Superfraggle
  • Members
  • 1019 posts

Posted 11 May 2008 - 10:09 PM

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

#Ifwinactive, ; Blank to turn off any limitations.


#11 Slekvak

Slekvak
  • Guests

Posted 11 May 2008 - 10:28 PM

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

#12 Superfraggle

Superfraggle
  • Members
  • 1019 posts

Posted 12 May 2008 - 12:01 AM

Your code should be as follows

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


#13 Kandou Erik

Kandou Erik
  • Guests

Posted 23 January 2011 - 09:58 AM

I still can't get it to work when playing a video full screen. How do I fix that. (And please, if possible, show me all text I should be putting in the file. I am not good with this script-thing - but I need that Pause/Space Bar button)

Please reply soon. Thank you.

#14 Kandou Erik

Kandou Erik
  • Guests

Posted 23 January 2011 - 02:51 PM

OK, I looked around and found another tread dealing with this same problem. See, as far as I can tell - it does pause WMP in full screen, but you have to wait for the information display (volume, play, ect) to fade away - AND THEN it will pause.

Still, that's very annoying not being able to pause it when the display is up. So - essentially I added the code I found with the code I already knew would pause WMP. This worked for me. I hope it will work for other people. Just copy and paste it exactly into the AutoHotKeys.

GroupAdd,mplayer,Windows Media Player
GroupAdd,mplayer,WMPTransition
GroupAdd, wmp, Windows Media Player
GroupAdd, wmp, ahk_class WMP Skin Host
GroupAdd, wmp, ahk_class WMPTransition
GroupAdd, wmp, FullScreenTopLayout
#IfWinActive, ahk_group wmp
Space::Send ^p
Enter::Send !{Enter}
#IfWinActive
#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


#15 lafingman0

lafingman0
  • Guests

Posted 24 February 2011 - 04:07 AM

wow thanks! this worked just as expected! I've been wanting something like this for so long. You fixed my WMP life man :D :D :D :D