Tuesday, August 26, 2014

keyboard - Set hotkeys using AutoHotkey to control Music


I have a new pc with Windows 10 and three hotkey keys (f2, f9 and f10) are not used.
On my old pc I had 3 keys dedicated to music: one paused/play, and the other two were to go to the next or previous song.


They were very useful, I used Spotify to list music. Now I don't have them anymore and I would like to set the keys f2, f9 and f10 so that they do the same things: f2 pause/play, f9 previous song and f10 next song.


I downloaded AutoHotkey and read the introduction tutorial but I don't understand what to write in my script. Also I don't even know where to save the script, for the moment it's on the desktop but I do non't like it very much.


I have already read this post that allows you to set the arrow keys in a similar way to what I need, but again, similarly. I want to set other keys.


Some help would be very welcome.


Thank you


Answer




I don't understand what to write in my script.



For practical purposes, the basic format for AutoHotKey scripts is:


replacement_key::original_key

So if you wanted to make the a key actually trigger the z key, you would write:


a::z

You can (potentially) put as many of these combinations as you like into a script but each one has to appear on a new line.


If you wish to make scripts which are more complicated, you should check out the official AutoHotKey hotkey documentation.



I would like to set the keys f2, f9 and f10 so that they [trigger media keys]: f2- pause/play, f9- previous song and f10 - next song.



Each media key has its own special representation in AutoHotKey. Consulting the official AutoHotKey keylist and its section on media keys, we can see the ones you are interested in are represented as Media_Play_Pause, Media_Prev and Media_Next. Likewise, we can see that the F keys are simply written as normal (e.g. f1).


Taking what we know so far, we can now write the following script:


f2::Media_Play_Pause
f9::Media_Prev
f10::Media_Next

Note that you will typically want to save your scripts with an .ahk extension (e.g. as media_keys.ahk, for instance.)



I don't even know where to save the script.



You can save it wherever you like. For the most part, its location shouldn't matter.


That said, keep in mind that you do need to have the script running to have your F keys work as media keys. If you want to have the script start with Windows, you may want to put a shortcut to it in your Startup folder.



Why do I have to use the Fn key for some options to work?



An Fn key is a modifier key that activates the secondary function of a "dual-purpose" key on a keyboard.


These "dual-purpose" keys are often found on smaller laptops, where the F keys (or others) may, in addition to their normal uses, have special functions (e.g. such as controlling audio volume). This is often done to save space on the keyboard layout.


If you have to press an Fn key to get some of the script options above to work, this likely means that the laptop manufacturer has assigned the "normal" operation of the F keys as a secondary function (and the unmodified F key does something else).


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...