Apple AirPort System Preferences Script

I need a little help and I need it fast. I am an admin for an Education company and I recently deployed 200 macbook laptops with out the correct network settings I am working on a script that will allow me to change the airport setting to make them more secure.

The script I pasted below has me in the right directions, but I cant figure out how to select all three boxes. Then I want to add the administrator name to the name field and password to the password field and click ok then apply.

Please HELP!

Settings I need :

Open System Preferences → Networks → AirPort → AirPort Avanced

Check-

Remember Anynetwork this computer joined - check

Disconnect from wireless network when logging out - checked

Require Administrator password to Control AirPort - Checked

Click (ok) button

Enter (this text) into Name Field

Enter (this text into Password field

Click (OK)

CLick (Apply)

Close Window

Current Script:

tell application "System Preferences"
	
	activate
	
	reveal anchor "AirPort" of pane "Network"
	reveal anchor "Advanced AirPort" of pane "Network"
	tell application "System Events" to tell process "System Preferences" to click checkbox 1 of window 1
	tell application "System Events" to tell process "System Preferences" to click checkbox 3 of group 1 of window 1

end tell

Model: MacBook 10.5.8
AppleScript: 2.2.1
Browser: Firefox 3.5.2
Operating System: Mac OS X (10.5)

Edit: Sorry, I just checked and on Snow Leopard the changes are not saved on Apply.
Click the Advanced button after running the script to see if the check boxes are still checked.

This will get you a little further. The application UIBrowser is a big help when GUI scripting.

Regards,

Craig


tell application "System Preferences"
	activate
	reveal anchor "AirPort" of pane "Network"
	reveal anchor "Advanced AirPort" of pane "Network"
	tell application "System Events"
		tell process "System Preferences"
			click checkbox 1 of window 1
			click checkbox "Disconnect when logging out" of tab group 1 of sheet 1 of window "Network"
			click checkbox "Create computer-to-computer networks" of tab group 1 of sheet 1 of window "Network"
			click checkbox "Change networks" of tab group 1 of sheet 1 of window "Network"
			click checkbox "Turn AirPort on or off" of tab group 1 of sheet 1 of window "Network"
			click button "OK" of sheet 1 of window "Network"
			click button "Apply" of window "Network"
		end tell
	end tell
end tell

One other option is to use mouse clicks. Not the best option but an option none-the-less. :wink:
You would need to check if the checkbox had already been
checked before clicking it or it would uncheck the box.

The click coordinates below are based on my screen resolution
and position of the window.

The easiest way to get a mouse-click position is to
[ shift + command + 4 ], hover the cross hairs over
the target and read the coordinates.

This line broken down.
“/usr/local/bin/cliclick -w 50 248 648 248 690 248 709 248 731”

– path to the cliclick program on MY computer
– change this to the correct location on your computer
/usr/local/bin/cliclick

– This is a millisecond delay between clicks
-w 50

– Groups of coordinates
248 648 248 690 248 709 248 731


-- requires free CLI program cliclick
-- http://www.bluem.net/en/mac/cliclick/
tell application "System Preferences"
	set bounds of window 2 to {99, 354, 750, 860}
	set bounds of window 1 to {99, 354, 750, 860}
end tell

do shell script "/usr/local/bin/cliclick -w 50 248 648 248 690 248 709 248 731"

I am not sure why but from the first script that you did. it too works on my mac with snow leopard but runs into issue when i try to run it on OSX 10.5.8.

It gives me an error message of:

can’t get “Disconnect when logging out” of > 1 of 1 of window “Network” of “System Preferences” of application “System Events”

I am worried about using click it because the screen resolutions aren’t all the same because some are connected to monitor.

I really appreciate all of your help with this.