Automator AppleScript not working

I have the following AppleScript commands in an Automator workflow that I then saved as a Service:


tell application "System Events"
	set _Date to (current date)
	keystroke ¬
		(year of _Date as text) & "-" & ¬
		text -2 thru -1 of ("00" & ((month of _Date) as integer)) & "-" & ¬
		text -2 thru -1 of ("00" & ((day of _Date) as integer)) & " - "
end tell


In High Sierra this used to allow me to insert the current date in a standardized format anywhere in the OS, e.g. in notes, while editing a filename, etc. It no longer works in Mojave or later. Is there a change that needs to be made when invoking the System Events application?

MacBook Pro 13″, macOS 10.12

Posted on Dec 23, 2020 12:50 PM

Reply

Similar questions

1 reply

Dec 23, 2020 11:28 PM in response to shaolin11

The script works as expected for me. However, a lot of things have changed with regard to services and cross-application interaction. Your script may not have permission to manipulate another application's space (although the OS is usually pretty good about notifying you when this happens).


There may also be a difference if you're running an old service written/compiled on an old OS version, compared to a new one written under the new security model.


Does it work if you create a new workflow/quick action?

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Automator AppleScript not working

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.