Created
October 2, 2009 01:00
-
-
Save mikew/199359 to your computer and use it in GitHub Desktop.
Helper scripts to send applescript key codes from terminal input
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
#!/bin/sh | |
osascript - <<EOF | |
tell application "System Events" | |
key code $1 | |
end tell | |
EOF |
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
#!/bin/sh | |
ord() { | |
printf '%d' "'$1" | |
} | |
TRANSLATIONS=([106]=126 [107]=125 [104]=123 [108]=124 [102]=36 [97]=53) | |
until [ "$INPUT" == "q" ]; do | |
read -n 1 -s INPUT | |
char=$(ord $INPUT) | |
keycode=${TRANSLATIONS[$char]} | |
if [ "x$keycode" != "x" ]; then | |
$(keycode $keycode) | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment