Created
January 3, 2012 08:41
-
-
Save tastycode/1554123 to your computer and use it in GitHub Desktop.
midi2key
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on runme(message) | |
if (item 1 of message = 176) and (item 2 of message = 19) then | |
tell application "System Events" to keystroke return | |
end if | |
if (item 1 of message = 176) and (item 2 of message = 20) then | |
tell application "System Events" to keystroke space | |
end if | |
if (item 1 of message = 176) and (item 2 of message = 103) then | |
tell application "System Events" to keystroke (ASCII character 8) | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 71) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "x" | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 60) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "k" | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 49) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "e" | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 66) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "r" | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 55) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "d" | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 72) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "y" | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 61) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "l" | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 50) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "i" | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 67) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "s" | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 56) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "f" | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 73) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "z" | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 62) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "m" | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 51) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "o" | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 68) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "t" | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 57) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "g" | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 63) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "n" | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 52) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "u" | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 69) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "v" | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 58) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "h" | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 64) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "p" | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 53) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "b" | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 70) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "w" | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 59) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "j" | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 48) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "a" | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 65) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "q" | |
end if | |
if (item 1 of message = 144) and (item 2 of message = 54) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "c" | |
end if | |
end runme |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% | |
system_keycode_map = { | |
19 => "return", | |
103 => "(ASCII character 8)", | |
20 => "space" | |
} | |
note_control_map = { | |
48 => "a", | |
49 => "e", | |
50 => "i", | |
51 => "o", | |
52 => "u" | |
}·· | |
remaining = ("a".."z").to_a - note_control_map.values | |
remaining.each_with_index do |letter, i| | |
code = 52+(i+1) | |
note_control_map[code] = letter | |
end | |
%> | |
on runme(message) | |
<% system_keycode_map.each do |code, cmd| %> | |
if (item 1 of message = 176) and (item 2 of message = <%=code%>) then | |
tell application "System Events" to keystroke <%=cmd%> | |
end if | |
<% end %> | |
<% note_control_map.each do |code, key| %> | |
if (item 1 of message = 144) and (item 2 of message = <%=code%>) and (item 3 of message > 0) then | |
tell application "System Events" to keystroke "<%=key%>" | |
end if | |
<% end %> | |
end runme |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment