OSX 10.9.1, Late 2013 MBPr

I am trying to make a Automator workflow to connect to another machine on my network. How can I do this with Automator? I have it all set up up to the point where I have to enter and admin's name and password, but I can't find a way to simulate keystrokes that actually works. I found a method that sounded legitimate here, but this did not work for shift-tab (as the field selected on launch is the password, and I need to edit the username and password).

I tried this AppleScript, which is what that post told me to do:

on run {input, parameters}

tell application "System Events"
    keystroke (tab) using {shift down}
end tell

return input
end run

The Automator workflow claims to have finished with no error, but the field selected on launch is still selected. How can I successfully select this field? Thanks!

  • Could we back up just a fraction. Why are you attempting to connect to the machine - file sharing, screen sharing? It may be easier to do the entire connection from the command line. – Tony Williams Feb 24 '14 at 0:05
  • @TonyWilliams Screen Sharing, with a 10.9.1 Late 2013 iMac. – nloveladyallen Feb 24 '14 at 1:53

I'm answering the original question in the title in case people are searching for it and navigate to this page.

  • You don't need to put shift down in curly braces, unless it's a comma separated list.
  • If the "tab" in parenthesis doesn't work, try the key code.
  • For each key press, try telling System events to do so without end tell.

Depending on your application, you need to specify which application you are telling to do the commands, and other parameters such as the window.

For example, in Safari, with the suggestions above:

tell application "Safari"
    tell front window
       tell application "System Events" to key code 48 using shift down
    end tell
end tell

If you want to automate Screen Sharing then the easiest way is to save a connection file.

Connect to the computer whose screen you want, making sure to save the password. Now go to the "File" menu and save the connection. You will get a file that can be easily opened from the command line or in Automator, or even just double clicked in the Finder. I do it most nights.

  • Yes, I did that, and automated opening that file, and once I open the file (with Automator or with Finder), a window appears for me to enter a username and password. I need to select the first field to type into (or, rather, Automate typing into). – nloveladyallen Feb 24 '14 at 11:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .