Because I use my ibook both at work and at home, I had two network settings setup (locations); 1 is called home and 1 is called work.
Everytime I login at work or home, I will need to goto system preferences to change the location to work or home.
Is there a script that I can write to change the location automatically… and I can put the respective script as a login item so that the location can be changed automatically.
I had looked into the dictionary but cannot find anything regarding change of location.
Changing location from the apple menu was what i had been doing throughout.
However, there are occasions, esp in the MORNING, when I got in work half awake, i login work account and go into Microsoft Outlook right away (which is running under classic) and TOTAL FORGOT to change location.
This is annoying as my outlook will fail with the worng location selected…
so I need to quit it, change location, relaunch classic, took 3 mins and back to operation.
Well… is there a way to script apple menu to automate this task??
:shock: You threw me off in your original post with “Everytime I login at work or home, I will need to goto system preferences to change the location to work or home.”
If you are running OS X 10.2.3 or later, you might be able to use GUI Scripting.
I had found this important info from GUI regarding changing network location:
Below is the script:
tell application “Finder”
activate
end tell
tell application “System Events”
get properties
get every process
tell process “Finder”
get every menu bar
tell menu bar 1
get every menu
tell menu “Apple”
get every menu item
tell menu item “Location”
get every menu
tell menu “Location”
get every menu item
get properties of every menu item
click menu item “Automatic”
end tell
end tell
end tell
end tell
end tell
end tell
Okei… this script makes sense to me… I sort of know what it is trying to do…
The script CAN PASS CHECK SYNTAX, but got an error when excute…
Here is the error message at “Tell menu bar 1, get every menu”
Execution error:
System Events got an error
NSReceiverEvaluationScriptError: 4
I have no idea what this this…
Can anyone please help me…
One thing that’s easy to miss when first installing GUI scripting is a setting in the Universal Access pref pane. You need to turn on “Enable access for assistive devices”. Have you done this?