Paste keystrokes automatically with Apple Automator

Want to paste a text into some place?

image

Create an AppleScript with this code:

on run {input, parameters}
  delay 5

  tell application "System Events"
    repeat with charOfInput in (characters of (input as text))
      set asciiValue to ASCII number of charOfInput
      -- Check if ASCII value is in the range of uppercase letters (65-90)
      if asciiValue  65 and asciiValue  90 then
        key down shift
        keystroke charOfInput
        key up shift
      else
        keystroke charOfInput
      end if
      delay 0.1
    end repeat
  end tell

  return input
end run

I created an app called Paste Keystrokes, the final result can look like this:

image

App not allowed to send keystrokes

If you get issues like thiis:

The action “Run AppleScript” encountered an error: “System Events got an error: Paste Keystrokes is not allowed to send keystrokes.

  1. Go to System Preferences > Privacy & Security > Accessibility
  2. Remove your app if listed there
  3. Re-add your app to the list

2024-02-21-11h39-screenshot@2x

Happy coding! – Found a mistake or a typo? Please submit a PR to my GitHub-repo.

Like this post? Follow @adriaandotcom on X