Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Cannot use 'tell application "System Events" to keystroke

I've been using this for some years now with ARD to log into whole labs when we are doing work on them. As you can see below I would use this command to have an entire lab login for me. As of OS X Mavericks it would see you cannot use osascript -e? Can someone help me create a method that works with Mavericks that does the following?


osascript -e 'tell application "System Events" to keystroke “xxxxusernamexxxx"'; \


osascript -e 'tell application "System Events" to delay 1.0'; \


osascript -e 'tell application "System Events" to keystroke return'


osascript -e 'tell application "System Events" to delay 4.0'; \


osascript -e 'tell application "System Events" to keystroke “xxxxpasswordxxxx"'; \


osascript -e 'tell application "System Events" to delay 1.0'; \

osascript -e 'tell application "System Events" to keystroke return’

Thank you!

Posted on Jul 15, 2014 12:02 PM

Reply
3 replies

Sep 12, 2014 8:48 AM in response to rccharles

Mavericks doesn't seen to give focus to the username field when booting up. A more sophisticated script could address this, but it would run afoul of the tighter security around access for assistive devices. The simpler solution is to run the command "killall loginwindow" before running osascript. When the loginwindow comes back, focus is on the username field so the osascript commands will work. You typically don't need the delay lines on modern hardware. If using ARD or a similar tool killall loginwindow must be run separately, since nothing coming immediately after it will be processed.

Cannot use 'tell application "System Events" to keystroke

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