Apple Script app help
I'm trying to make an applescript based app that can, with only one click, activate/deactivate both Network and Adium proxy settings. The Adium part is done. What I cannot do is to make a switch/if_then_else statement to chose between: Network / Location: "Automatic" and "uMinho" settings. The script should select the unactive option. Any ideas ?
Here is the script:
-- Activate Location "uminho"
tell application "Finder" to activate
tell application "System Events"
tell process "Finder"
tell menu bar 1
tell menu bar item "Apple"
tell menu "Apple"
tell menu item "Location"
tell menu "Location"
-- Need to switch between "Automatic" and "uMinho"
-- Switch to the unactive one
click menu item "uMinho"
end tell
end tell
end tell
end tell
end tell
end tell
end tell
-- Activate adium proxy settings to all accounts
tell application "Adium" to activate
-- let's do this
tell application "System Events"
tell process "Adium"
-- open prefs
k开发者_运维百科eystroke "," using command down
tell window 1
-- open the accounts pane
tell tool bar 1 to click button "Accounts"
repeat with i from 1 to count of rows of table 1 of scroll area 1
-- tell group 1
-- select the account
set selected of row i of table 1 of scroll area 1 to true
-- edit it
click button "Edit"
-- end tell
tell sheet 1
tell tab group 1
-- open the personal info pane
click radio button "Proxy"
-- change the name, if one was provided
click checkbox "Connect using proxy"
end tell
click button "OK"
end tell
end repeat
keystroke "w" using command down
end tell
end tell
end tell
In 10.5 or later this will work, else you can use the command line utility scselect to switch locations.
tell application "System Events"
tell network preferences
set currentName to name of current location
if currentName is "Automatic" then
set current location to location "uMinho"
else
set current location to location "Automatic"
end if
end tell
end tell
精彩评论