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).
Thank you! I tested the script and the f2 and f9 keys don't work, instead the f10 key works perfectly... – beth – 2018-04-23T11:50:36.450
I understand better what's happening. The pause/play works if I type
fn + F2
, the next song works if I typef9
, the previous song works if I typefn + f9
. Why for some options should I also typefn
? – beth – 2018-04-23T12:16:01.530fn
keys are used to activate the secondary functions of "dual-purpose" keys, especially on smaller keyboards. It sounds as if thef2
andf9
keys actually are used (for hardware or software control) and you have to press thefn
key to get them to send their "normal" F key signals. Moreover, if your statement about being able to usef9
as "Next Song" (Media_Next
) was accurate (and you didn't meanf10
), it sounds as if you might have (at least some) dedicated media keys... they may just be F keys. =P – Anaksunaman – 2018-04-23T14:11:49.203