Created
March 19, 2014 23:19
-
-
Save parano/9653676 to your computer and use it in GitHub Desktop.
Send random arrow keys using ruby, Mac OS X only
This file contains 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
#!/usr/bin/ruby -w | |
def presskey(keycode) | |
system "osascript -e 'tell application \"System Events\" to key code #{keycode}'" | |
end | |
kVK_LeftArrow = 123 | |
kVK_RightArrow = 124 | |
kVK_DownArrow = 125 | |
kVK_UpArrow = 126 | |
arrow_keys = [kVK_LeftArrow, kVK_RightArrow, kVK_DownArrow, kVK_UpArrow] | |
if $0 == __FILE__ | |
sleep(2) | |
while(true) do | |
presskey(arrow_keys.sample) | |
sleep(0.4) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another example (this one is multiline):