Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Nneon

macrumors newbie
Original poster
Nov 19, 2009
5
0
Hey,

I'm currently trying to write a script to automatically connect to another computer on my local network.

this is the script so far:
Code:
tell application "Screen Sharing"
	activate
	
	tell application "System Events"
		keystroke "kiryns-laptop.local"
		keystroke return
	end tell
	
end tell

I was hoping someone could help me get applescript to select the radio button that says connect "by asking for permission" and then hit return.

here's what it looks like:

Screenshot2009-11-20at32742PM.png


thanks in advance ;)
 

Nneon

macrumors newbie
Original poster
Nov 19, 2009
5
0
I'm still after a solution for this if anyone is able to help?
 

mysterytramp

macrumors 65816
Jul 17, 2008
1,334
4
Maryland
Do you have a file called "UIElementInspector.app" (I have it but for some reason I believe that it's pre-SL and has been discontinued). Run it and you'll get a windoid that will provide the proper nomenclature for radio buttons and other UI elements.

it'll probably be "Select button 1"

mt
 

larkost

macrumors 6502a
Oct 13, 2007
534
1
The better solution is to use a "vnc://" url. For example:

vnc://kiryns-laptop.local

I believe that you can even put in username/password and have those passed (but in the clear on the system... a bit dangerous on shared systems).
 

Nneon

macrumors newbie
Original poster
Nov 19, 2009
5
0
I'm still having trouble trying to work this one out... my experience with applescript is extremely limited.

I've tried adding:

Code:
delay 1
select button 1

and others like that but with no success.

If someone knows what I need to write instead and could help me out that would be greatly appreciated.
 

Nneon

macrumors newbie
Original poster
Nov 19, 2009
5
0
Thanks for the link but that's not really what I'm after.

I just need someone to tell me what I need to write to select that first radio button.

Everything I've tried so far doesn't want to work :(
 

Nneon

macrumors newbie
Original poster
Nov 19, 2009
5
0
Solved

@binaryassist from twitter was able to provide me with this solution for anyone else who may be interested.

Code:
tell application "System Events"
click (radio button 1 of radio group 1 of window 1) of application process "NetAuthAgent"

So my completed working AppleScript now looks like this:

Code:
tell application "Screen Sharing"
	activate
	
	tell application "System Events"
		keystroke "kiryns-laptop.local"
		keystroke return
		delay 1
		tell application "System Events"
			click (radio button 1 of radio group 1 of window 1) of application process "NetAuthAgent"
			keystroke return
		end tell
	end tell
	
end tell
 

AndreasFischlin

macrumors newbie
Apr 28, 2010
1
0
There is a simpler and more elegant solution

This works under Snow Leopard (Mac OS X 10.6.3):


Code:
(*

	Purpose	Single command connection established to another Mac such as an AirBook
	
	Usage	Launch this script
	
			Upon first time use you are likely having to enter user name and password. To allow for even more convenient connecting check the checkbox "Remember this password in my keychain"

			Set the preference targetMacsIPName to the IP name of the Mac to which you wish to connect.
			
			Note, the target Mac must have screen sharing enabled, choose menu command "Apple -> Systems Preferences... -> Sharing" and make sure checkbox "Screen Sharing" is checked)
			
	Programing	Andreas Fischlin, ETH Zurich, 28.Apr.2010 
				http://www.sysecol.ethz.ch/staff/af/			

*)

property targetMacsIPName : "air-andreas.local"

tell application "Screen Sharing"
	open location "vnc://" & targetMacsIPName
end tell
 

Rick Sustek

macrumors newbie
Feb 3, 2011
2
0
Also note, that you can launch the Screen Sharing app from a command line such as this:

open vnc://TheOtherComputer.local

The 'open' command knows what to do with that vnc URL, sending it to the Screen Sharing app.

Now then, since this can be done, then you can also create an Automator program that simply runs that command in a shell script item. Create a few of these for all the computers in your realm, plop them on your desktop, and you've got easy point-and-click launching for your remote sessions.

cheers,
-Rick
 

Rick Sustek

macrumors newbie
Feb 3, 2011
2
0
also, easy desktop icon

You can also make a simple launch icon the desktop without typing a thing:

1) Establish an active screen share to some computer

2) Drag the little title bar icon at the top of that window, to your desktop. It will automatically create a VNC link that can be then activated to launch a sharing session whenever you please.

Not sure if this helps the OP, as it was not clear if he just wanted a simple way to launch a screen session to specific machines, or really needed something that was part of a larger AppleScript workflow.

Cheers.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.