Skip to content

Instantly share code, notes, and snippets.

@vi7
Last active August 14, 2023 15:13
Show Gist options
  • Save vi7/0ecc3056bb72cb06d7797c0d95ad934a to your computer and use it in GitHub Desktop.
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
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