Last active
April 29, 2019 04:18
-
-
Save jaymcgavren/dd6c0d34ed5c6786d98e6ef4615fba10 to your computer and use it in GitHub Desktop.
Simulate typing out the clipboard contents! Save the below script as an AppleScript or a service in Automator.
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
set mytext to (the clipboard as text) | |
write_string(mytext) | |
on write_string(the_string) | |
tell application "System Events" | |
launch | |
repeat with the_character in the_string | |
keystroke the_character | |
delay (random number from 0.05 to 0.25) | |
end repeat | |
end tell | |
end write_string |
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
# based on https://christianheilmann.com/2014/01/09/autmating-typing-in-screencasts-with-applescript-or-how-to-look-like-a-hollywood-hacker/ | |
set my_text to (the clipboard as text) | |
set the text item delimiters to (ASCII character 13) # CR, not LF! | |
set my_lines to text items in my_text | |
repeat with current_line in my_lines | |
write_string(current_line) | |
end repeat | |
on write_string(the_string) | |
tell application "System Events" | |
launch | |
repeat with the_character in the_string | |
keystroke the_character | |
delay (random number from 0.01 to 0.12) | |
end repeat | |
key code 36 # enter | |
# Cope with autoindent by deleting to start of line | |
key code 123 using {shift down, command down} # left arrow | |
key code 51 # delete | |
end tell | |
end write_string |
I now have to work with an editor where I can't turn auto-indent off, so I included the aforementioned hack in simulate_typing_clipboard_cope_with_autoindent.txt
.
I'd also like to point out a weird coincidence: it's been a year to the day between comments. ¯\_(ツ)_/¯
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Inspired by http://christianheilmann.com/2014/01/09/autmating-typing-in-screencasts-with-applescript-or-how-to-look-like-a-hollywood-hacker/ (which includes a hack to make it work with editors where you can't turn auto-indent off).