Skip to content

Instantly share code, notes, and snippets.

@razhangwei
Last active April 19, 2022 19:59
Show Gist options
  • Save razhangwei/4d273f01eb336eabe4c3ea3539cda990 to your computer and use it in GitHub Desktop.
Save razhangwei/4d273f01eb336eabe4c3ea3539cda990 to your computer and use it in GitHub Desktop.
Inserting Date & Time on MacOS #Mac #Automator
  1. Open Automator and create Quick Action.
  2. In the middle column, look for Run AppleScript
  3. On the right, choose no input for workflow receives
  4. input
on run {input, parameters}
    set dateString to do shell script "date +'(%m/%d/%y %H:%M %p)'"
    tell application "System Events"
    	keystroke dateString
    end tell
    return input
end run
  1. save it Insert Datetime
  2. open Keyboard->Shortcuts->Services->General, check Insert Datetime and assign it with a preferred keyboard shortcut. (preferred Shift + Ctrl + Cmd + T)
  3. Allow the apps to AppleScripts: Security & Privacy -> Privacy -> Accessibility -> Whatever app you tried to run the AppleScript.

Trouble Shooting

“System Events got an error: Automator Workflow Runner (WorkflowServiceRunner, Insert Datetime) is not allowed to send keystrokes.

Security & Privacy -> Privacy -> Accessibility -> Whatever app you tried to run the AppleScript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment