Skip to content

Instantly share code, notes, and snippets.

@davebrny
Last active October 24, 2017 14:24
Show Gist options
  • Save davebrny/0fec50393cb06a4f51a13ec7d1b77b28 to your computer and use it in GitHub Desktop.
Save davebrny/0fec50393cb06a4f51a13ec7d1b77b28 to your computer and use it in GitHub Desktop.
▶️ (autohotkey) - turn any key into a media key, then double tap to send the original key
home::
goTo, media_prev
return
end::
goTo, media_play_pause
return
insert::
goTo, media_next
return
; - - - - - - - - - -
media_prev:
media_play_pause:
media_next:
this_key := regExReplace(a_thisHotkey, "[\W]") ; no symbols
keyWait, % this_key
keyWait, % this_key, D T.2
if errorLevel
send {%a_thisLabel%} ; single tap
else ; double tap
{
modifiers := regExReplace(a_thisHotkey, "[^\Q^!+#\E]") ; only hotkey symbols
stringReplace, key, a_thisHotkey, % modifiers, ,
send % modifiers "{" key "}"
}
return
/*
[script info]
version = 1.2
description = single tap to send a media key, double tap to send the original key
author = davebrny
source = https://gist.github.com/davebrny/0fec50393cb06a4f51a13ec7d1b77b28
*/
@davebrny
Copy link
Author

davebrny commented Dec 29, 2016

different keys can be combined if you want them to send the same media command:

f11::
pause::
end::
goTo, media_play_pause
return

if you are using multiple computers and want to send different commands from the same key name then use the a_computerName variable

insert::
if (a_computerName = "a")
    goTo, media_play_pause
else if (a_computerName = "b")
    goTo, media_next
return

if you want to use a double tap to send the media key and a single tap to send the normal key, then change line 21 to the following:

if !errorLevel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment