I've got a very simple AppleScript whose job it is to type some words into a text box.
tell application "TextEdit"
activate
end tell
delay 0.2
tell application "System Events"
keystroke "Hello World!"
keystroke return
end tell
I want this script to run every time my screen saver activates, and again every time my screen saver deactivates. I installed ScriptSaver and it works perfectly. So far, so good.
Except my screen locks when the screen saver activates. This means that when my script tells TextEdit to activate, the computer pops up its login window and thinks I'm typing "Hello World!" as a password. Not ideal.
I tried making the screen saver require a password after 5 seconds, instead of immediately, but that was no good: the process of activating TextEdit just wakes up the screen again.
Is there a way to activate TextEdit and type words into it in the background, without making my computer think I'm trying to unlock the screen?