1

I'm trying to remap the function keys to their secondary function as a default nut I'm running into a few issued in the code. One thing to note is that, in my keyboard driver software, I can switch the Fn key to be a right windows key so I can avoid the low level coding issues involved with the Fn key.

I have written the following and the first bunch of hotkeys seem to work fine:

RightWindowsDown := 0

F1::Send {Volume_Mute}
F2::Send {Volume_Down}
F3::Send {Volume_Up}
F4::Send {Launch_App2}
F5::Send {Media_Play_Pause}
F6::Send {Media_Stop}
F7::Send {Media_Prev}
F8::Send {Media_Next}
F9::Send {Launch_App1}


RWin:: 
{
    RightWindowsDown:=1
    soundbeep
}

If (RightWindowsDown = 1)
{
    F1::F1
    F2::F2
    F3::F3
    F4::F4
    F5::F5
    F6::F6
    F7::F7
    F8::F8
    F9::F9
}

return

However, when I press the RWin key, it just spams the normal F1 key and opens up a load of help pages. Any ideas on how I can avoid this?

  • Pretty much all such keyboards have some way for an "FN Lock" to achieve this without any tools. Did you try that before? – Mario Apr 26 '17 at 5:29
0

Try this and see if it works a little better. I've included an #If directive. It tells AHK "Hey, only let these work if the #If directive returns true". When you hit F1-F9, it'll check to see if you're holding RWin first. If you are, it uses the alternate hotkey.

#SingleInstance, Force
return

F1::Send {Volume_Mute}
F2::Send {Volume_Down}
F3::Send {Volume_Up}
F4::Send {Launch_App2}
F5::Send {Media_Play_Pause}
F6::Send {Media_Stop}
F7::Send {Media_Prev}
F8::Send {Media_Next}
F9::Send {Launch_App1}

#If GetKeyState("RWin", "P")
F1::F1
F2::F2
F3::F3
F4::F4
F5::F5
F6::F6
F7::F7
F8::F8
F9::F9

References:
#If
GetKeyState

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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