Autohotkey: Global Media Keys

Requirements

Installation

  1. copy/paste the code from the script below into a new file
  2. save that new file in a new folder (you can name it whatever you want)
  3. run the script
  4. done

Usage

  1. manually run the script once, it stays active unless you manually close it (if you use it frequently, you might want to consider adding it to your computers startup)
  2. done

Script

app_name = GlobalMediaKeys
app_ver = 0.01
app_author = Johan Klos

/*
Not every keyboard has media-keys. With this plugin you have default global media keys (CTRL-WIN-ALT up/left/right). 
If the script is Run as Admin (line 16: "runasadmin = 1") the hotkeys will work even if a program has focus that is running as admin.
If the script is not Run as Admin (line 16: "runasadmin = 0"), the hotkeys will not work when a program has focus that is running as admin.
*/

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

runasadmin = 0

if runasadmin = 1 
{
	full_command_line := DllCall("GetCommandLine", "str")

	if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
	{
		try
		{
			if A_IsCompiled
				Run *RunAs "%A_ScriptFullPath%" /restart
			else
				Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
		}
		ExitApp
	}
}

^#!UP::Media_Play_Pause
^#!RIGHT::Media_Next
^#!LEFT::Media_Prev

return

 

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Loading