Last active
January 13, 2016 08:33
-
-
Save ChunMinChang/5df91b4d07ccd8016499 to your computer and use it in GitHub Desktop.
Simulate hardware keyboard 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/bash | |
# Get the simulated key | |
KEY=$1 | |
#print variable on a screen | |
echo "Send heardware key '$KEY'" | |
case "$OSTYPE" in | |
darwin*) | |
echo "OSX" | |
# osascript -e 'tell application System Events" to key code 0' | |
# osascript -e 'tell application "System Events" to keystroke "a"' | |
osascript -e 'tell application "System Events" to keystroke "'$KEY'"' | |
;; | |
linux*) | |
echo "LINUX" | |
# Rely on 'xdotool': | |
# You should install it by 'sudo apt-get install xdotool' | |
xdotool key $KEY | |
;; | |
solaris*) echo "SOLARIS" ;; | |
bsd*) echo "BSD" ;; | |
*) echo "unknown: $OSTYPE" ;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment