My work's closed network seems to need someone to (in pseudo code) to invoke AirPort, Choose Other Network and re-key the name and password. Unfortunately, I don't seem to be able to find the correct syntax to make the below (or variant) run.
--Script to free specialist from rekeying the Network passcode every day
on restartAirPort() --invoke application tell application "AirPort"
tell application "Finder"
activate
end tell
tell application "System Events"
if UI elements enabled then
click menu item "Automatic" of menu "Location" of menu item "Location" of menu "Apple" of menu bar 1 of process "Finder"
else
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.universalaccess"
display dialog "UI element scripting is not enabled. Check \"Enable access for assistive devices\""
end tell
end if
end tell
--tell application "AirPort"
activate
--Is this for Network?
display dialog "Network" buttons {"Yes", "No"} default button "Yes"
if button returned of the result is "No" then
set theNetwork to false
else
set theNetwork to true
end if
--Establish network parameters
--Set Closed Network Name to abcd
--set 128-bit Hex to "abcdefghijklmnopqrstuvwxyz"
--tell button "Connect" of tool bar 1 to click
--delay 2
end restartAirPort