Clicking buttons...arrrrggghh!!!


I have been attempting to creat a script that clicks the “Connect” button on my “Connect to Servers” window so that I don’t have to fiddle with keystroke commands. The keystrokes I have written work sometimes and then other times it just freezes. I just want to see if I can replace these keystroke commands with a button click; can anyone help?

Thanks, Brian

Like zo:

activate application "Finder"
tell application "System Events" to tell process "finder"
	keystroke "k" using {command down}
	delay 0.5
	keystroke return
end tell

Thanks Adam,

I do have that much down. I have also written the password into the script because I did not want to save it in my keychain. The problem that I am running into is that after I have the script enter into the password text box and type out the password, it has difficulty doing the Return keystroke. I have tried adding delays, adding a tab keystroke or two, with limited success. It seems as if the script behaves differently each time I use it.


Thanks to Adam’s answer to my post on finding UI elements, I have been able to solve this scripting dilemma. I just needed the right name of the buttons and processes.

Thanks again Adam!


This worked for me:

activate application "UserNotificationCenter" -- the app putting up the window
tell application "System Events" to tell window 1 to keystroke return