Last active
August 14, 2023 15:13
-
-
Save vi7/0ecc3056bb72cb06d7797c0d95ad934a to your computer and use it in GitHub Desktop.
Apple script to auto type clipboard contents. To use in the macOS Automator Quick Action
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
on run {input, parameters} | |
tell application "System Events" | |
set textToType to (get the clipboard as text) | |
delay 1 | |
repeat with i from 1 to count characters of textToType | |
set c to character i of textToType | |
-- use codes to print some chars for compatibility reasons | |
-- see https://eastmanreference.com/complete-list-of-applescript-key-codes for all key codes | |
if c = "." then | |
key code 47 | |
delay 0.01 | |
else if c = "=" then | |
key code 24 | |
delay 0.01 | |
else if c = "1" then | |
key code 18 | |
delay 0.01 | |
else if c = "2" then | |
key code 19 | |
delay 0.01 | |
else if c = "3" then | |
key code 20 | |
delay 0.01 | |
else if c = "4" then | |
key code 21 | |
delay 0.01 | |
else if c = "5" then | |
key code 23 | |
delay 0.01 | |
else if c = "6" then | |
key code 22 | |
delay 0.01 | |
else if c = "7" then | |
key code 26 | |
delay 0.01 | |
else if c = "8" then | |
key code 28 | |
delay 0.01 | |
else if c = "9" then | |
key code 25 | |
delay 0.01 | |
else if c = "0" then | |
key code 29 | |
delay 0.01 | |
else | |
keystroke c | |
delay 0.01 | |
end if | |
end repeat | |
-- use for a ligtning fast way | |
-- keystroke textToType | |
end tell | |
return input | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment