Re: UI Scripting Network...
Re: UI Scripting Network...
- Subject: Re: UI Scripting Network...
- From: Bill Cheeseman <email@hidden>
- Date: Thu, 29 Apr 2004 19:03:03 -0400
on 2004-04-29 5:21 PM, Martha Espinosa at email@hidden wrote:
>
I am trying to create a GUI applescript that edits the Network
>
Location. I can change the location but I cannot edit or create a
>
new location. Has anyone gotten this to work?
This will work:
tell application "System Preferences" to activate
tell application "System Events"
tell application process "System Preferences"
click menu item "Network" of menu "View" of menu bar 1
delay 1
tell window "Network"
click pop up button 1
delay 1
tell menu "OtherViews" of pop up button 1
click menu item "New Location
"
end tell
delay 1
tell sheet 1
keystroke "My New Location"
delay 1
click button "OK"
end tell
end tell
end tell
end tell
There are several obscure points about GUI Scripting illustrated here:
1. The ellipsis in menu item "New Location..." is the single ellipsis
character obtained by typing Option-;. Some applications use three periods.
You sometimes have to try it both ways to see which works with any
particular application.
2. Pop-up buttons have a hidden menu named "OtherViews". You have to include
it in your reference to the menu item. (Is that how your script changes
locations, or did you find another way?)
3. The text field in the sheet where you enter the name of a new Location in
the Network preference pane won't let you set its value. You have to resort
to the System Events 'keystroke' command and let AppleScript type it in. To
allow time for it to type a long name before the script clicks the "OK"
button, you have to append a 'delay' command.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.