Set hotkeys using AutoHotkey to control Music

0

1

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

beth

Posted 2018-04-23T07:45:17.610

Reputation: 103

Answers

1

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).

Anaksunaman

Posted 2018-04-23T07:45:17.610

Reputation: 9 278

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 type f9, the previous song works if I type fn + f9. Why for some options should I also type fn? – beth – 2018-04-23T12:16:01.530

fn keys are used to activate the secondary functions of "dual-purpose" keys, especially on smaller keyboards. It sounds as if the f2 and f9 keys actually are used (for hardware or software control) and you have to press the fn key to get them to send their "normal" F key signals. Moreover, if your statement about being able to use f9 as "Next Song" (Media_Next) was accurate (and you didn't mean f10), 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

1

Have you tried something like this?

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

barro32

Posted 2018-04-23T07:45:17.610

Reputation: 71

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:45.987

I understand better what's happening. The pause/play works if I type fn + F2, the next song works if I type f9, the previous song works if I type fn + f9. Why for some options should I also type fn? – beth – 2018-04-23T12:16:07.253