I recently bought a Filco Majestouch Ninja mechanical keyboard. It doesn’t come with all the fancy function keys, therefore I decided to create some function keys myself. I installed the AutoHotKey (AHK) tool and wrote an AHK script. I use the Windows key as a replacement for the Function (Fn) key typically found on laptop keyboards. Here is a list of my function key mappings.

ShortcutFunctions
Win+EscPut computer to sleep
Win+F6Toggle volume mute
Win+F7Turn master volume down
Win+F8Turn master volume up
Win+F9Skip to previous song
Win+F10Play or pause song
Win+F11Skip to next song
Win+F12Open Network And Sharing Center

I use a Windows 7 on my desktop, but I found the Power User Menu shortcuts in Windows 8 come in handy, so I created them too. The Power User Menu is the pop-up menu which is displayed on the bottom left corner when you press Win+X on a Windows 8 computer. The script will not display the menu, so you need to remember the shortcut keys.

ShortcutFunctions
Win+X, FProgram and Features
Win+X, BMobility Center
Win+X, OPower Pptions
Win+X, VEvent Viewer
Win+X, YSystem
Win+X, MDevice Manager
Win+X, KDisk Management
Win+X, GComputer Management
Win+X, CCommand Prompt
Win+X, ACommand Prompt (Admin)
Win+X, TTask Manager
Win+X, PControl Panel
Win+X, EExplorer
Win+X, SSearch
Win+X, RRun
Win+X, DDesktop

Here goes the script.

; Put computer to sleep (Win + Esc)
#Esc::
; Sleep/Suspend:
DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0)
; Hibernate:
;DllCall("PowrProf\SetSuspendState", "int", 1, "int", 0, "int", 0)
Return
;; Volume control
; Toggle mute (Win + F6)
#F6::Send {Volume_Mute}
; Turn master volume down (Win + F7)
#F7::Send {Volume_Down}
; Turn master volume up (Win + F8)
#F8::Send {Volume_Up}
;; Media control
; Prev song (Win + F9)
#F9::Send {Media_Prev}
; Play or pause (Win + F10)
#F10::Send {Media_Play_Pause}
; Next song (Win + F11)
#F11::Send {Media_Next}
; Show Network control panel (Win + F12)
#F12::Run, %windir%\system32\control.exe /name Microsoft.NetworkandSharingCenter
; Shutdown (Win + Ctrl + F12)
#^F12::Run, shutdown /s /t 0
;; Emulate Windows 8 Power User Menu, i.e Win+X Menu
#x::
Input Key, L1 T3
; Desktop
if Key = d
Run, %windir%\explorer.exe shell:::{3080F90D-D7AD-11D9-BD98-0000947B0257}
; Run
else if Key = r
Run, %windir%\explorer.exe shell:::{2559a1f3-21d7-11d4-bdaf-00c04f60b9f0}
; Search
else if Key = s
Run, %windir%\explorer.exe shell:::{2559a1f8-21d7-11d4-bdaf-00c04f60b9f0}
; Explorer
else if Key = e
Run, %windir%\explorer.exe /e,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}
; Control Panel
else if Key = p
Run, %windir%\system32\control.exe
; Task Manager
else if Key = t
Run, %windir%\system32\taskmgr.exe /0
; Command Prompt (Admin)
else if Key = a
DllCall("shell32\ShellExecute", "uint", 0, "str", "runas", "str", "C:\Windows\System32\cmd.exe", "str", "", "str", "", "int", 1)
; Command Prompt
else if Key = c
;Run, %windir%\system32\cmd.exe
DllCall("shell32\ShellExecute", "uint", 0, "str", "open", "str", "C:\Windows\System32\cmd.exe", "str", "", "str", HOMEDRIVE . HOMEPATH, "int", 1)
; Computer Management
else if Key = g
Run, %windir%\system32\compmgmt.msc
; Disk Management
else if Key = k
Run, %windir%\system32\diskmgmt.msc
; Device Manager
else if Key = m
Run, %windir%\system32\control.exe /name Microsoft.DeviceManager
; System
else if Key = y
Run, %windir%\system32\control.exe /name Microsoft.System
; Event Viewer
else if Key = v
Run, %windir%\system32\eventvwr.exe
; Power Options
else if Key = o
Run, %windir%\system32\control.exe /name Microsoft.PowerOptions
; Mobility Center
else if Key = b
Run, %windir%\system32\mblctr.exe
; Programs and Features
else if Key = f
Run, %windir%\system32\control.exe /name Microsoft.ProgramsAndFeatures
return
view raw fkeys.ahk hosted with ❤ by GitHub