Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How do I make the key combination Win + . send the instruction to media_next?

I have tried writing in several different ways but I always get a script error.

My objective is to press the keys Win and . and have the music players skip to the next track.

Please tell me the exact sentence as I'm completely new to scripting and one character missing, for example, will be a huge obstacle for me...

Not so important: should I be writing these instructions in autohotkey.ahk or in shortcuts.ahk?

Thank you very much!

share|improve this question
1  
What have you tried so far? What isn't working? What error messages are showing? What media program are you trying to work with? What instruction are you trying to send? According to a brief perusal of the Autohotkey docs, media_next is not a valid command... –  darthbith Sep 4 '13 at 3:03
    
@darthbith, sure it is. –  Synetech Sep 4 '13 at 3:25
    
Well, media_next isn't a command on its own, but Send {media_next} is. I do agree with @darthbith that questioners should generally show that they have tried to solve the question themselves, and explain what they've done. –  Dane Sep 4 '13 at 3:28
1  
@Dane, cybergofer never said anything about a media_next “command”; they were clearly asking about remapping Win+. to the Media_Next key. Nevertheless, see my answer below; media_next may not be a “command”, but it works like one in this context. –  Synetech Sep 4 '13 at 3:31
    
Any particular reason you want that specific hotkey to be mapped to media-next? It seems like kind of an key for this purpose, yet you’re not the first to request it. ಠ_ఠ –  Synetech Sep 4 '13 at 3:54

3 Answers 3

This should work (I tested it with VLC and XMPlay):

#.::Media_Next

It sends the media-next key to just the active window, so if you want to use the hotkey while watching a full-screen movie or something, it would do the trick. If you are watching a video in the corner of the screen while working on other things, then you’ll need to send the key globally:

#.::Send {Media_Next}

Of course your media-player must be able to detect and respond to the actual media keys. Some are written to do so by default, some you can set to do so in their key-mapping configuration, others do so automatically when they have the appropriate file-type associations.

As Sonamor pointed out, you can target the hotkey to specific windows in case you have multiple media-players running that all respond to the media-keys (though in my experience, the first one that runs tends to register the key and thus block others from receiving it; so you could just shut them all down and run the one you want).


In response to the more detailed question

I keep trying and I always get error. This is what I've tried the last time:

LWin + ,::{Media_Next}

I've also tried:

Win + .::Media_Next

There’s several things wrong with those lines:

  • The + denotes the ⇧ Shift key, so the hotkey only work when ⇧ Shift is held down
  • The ; is the ; key, so it only works when the ; key is held down
  • You can’t use {Media_Next} as the operation, you can use either:
    • Send {Media_Next} to send the media-next key in general or
    • Media_Next to send the media-next key to just the active window
  • Win is not valid, you need to use # as a modifier
  • LWin is only valid to use ⊞ Win the hotkey. As a modifier, you must use <#.

So in your case, you probably want this:

<#.::Send {Media_Next}


*I only have one "win" key on my keyboard.

Then why make it specific to the left Windows key? If there’s only one, then it makes no difference which you specify. In fact, it is safer to just use the generic version in case for some reason, the manufacturer decided to use the scancode for the other key. You may as well just use this:

#.::Send {Media_Next}
share|improve this answer
    
Whoa! I just checked this out and it blew me away. It looks like any named key can be handled this way. I'm going to have to experiment some more... –  Dane Sep 4 '13 at 3:33
    
@Dane: I haven't tried that one yet. Thanks! Sorry about not having my previous attempts recorded but, at the time, I didn't think I would be needing them especially after finding out they had errors Thank you very much! –  cybergofer Sep 4 '13 at 4:10
    
Wow! Thank you very much! :) . Again, sorry for commenting for thanking but I had to. That was exactly what I was looking for (skipping tracks while working on other stuff):) Thank you Synetech! –  cybergofer Sep 4 '13 at 4:24
    
That information about other media-players will very likely come in handy! –  cybergofer Sep 4 '13 at 6:43

You can add the following line to your autohotkey.ahk file, save, and then right-click on the AutoHotKey icon in your tray select, Reload This Script:

#.::Send {Media_Next}
share|improve this answer
    
Thank you very much Dane! That way I don't have to have two scrips on the system tray heheh :)! Thank you very much everyone! –  cybergofer Sep 4 '13 at 4:26
    
I've managed to recover two of my past failed attempts (just as a curiosity now since the problem is solved :) LWin + ,::{Media_Next} I've also tried: Win + .::Media_Next Thank you very much! :) –  cybergofer Sep 4 '13 at 5:22
    
So, it looks like the main thing was using #. instead of Win + . –  Dane Sep 4 '13 at 6:13
    
It looks like that was the problem (on those two tries. There were probably other different problems with all the others) heheh. This Autohotkey software is great! This is my first experience with scripting and I'm loving it. All the potential for doing other practical stuff :) –  cybergofer Sep 4 '13 at 6:37
    
I've become a big fan of AutoHotKey. I started with a few hotstrings for phrases and some hotkey shortcuts, but have now added some more advanced features (plain-text paste, Google highlighted text) and am attempting to grasp some even more complex things like parsing text and sizing/placing windows. –  Dane Sep 4 '13 at 13:50

You can also use the AutoIt3 Window Spy and make the hotkey work only for VLC Media Player

#IfWinActive, VLCWINDOW
#.::Media_Next
share|improve this answer
    
I thought we wanted it for VLC, my bad, but he got the point to make the Hotkey work for certain application. –  Sonamor Sep 4 '13 at 3:38
    
Wow this was fast! Thank you very much for your answers! @darthbith: I've tried and deleted so many of my ignorant attempts to write the correct script. It must have been more than 10 different combinations. But unfortunately, I can't remember exactly what I've tried. This is my last attempt: #.::{Media_Next} Thank you very much! –  cybergofer Sep 4 '13 at 4:09
    
Problem solved! Thank you very much Sonamor, it looks like #.::Media_Next works perfectly! Sorry about answering to thank you but I just can't be ungrateful :) –  cybergofer Sep 4 '13 at 4:21
    
Yes, Sonamor, I'm using it to skip tracks on Spotify. Sorry about not being more informative from scratch :) Thank you very much! –  cybergofer Sep 4 '13 at 4:59
    
Ok then use AutoIt3 Window Spy to find the Window name for Spotify, if you want the hotkey to work only if Spotify is focused or dont use the first line of the code if you want the hotkey to be universal. –  Sonamor Sep 4 '13 at 10:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.