Tag Archives: AppleScript

Is switching proxies on Mac OS 10.5 scriptable?

I often need to change the network proxies settings frequently due to the need to bypass the GFW when accessing websites that are considered “bad”, and have to set the settings back to not using any proxies when accessing “good” websites.

Doing so in Firefox is easy thanks to the little yet handy plugin called SwitchProxy, but for Safari or other applications which use the global system settings of Mac OS, one has to go through many steps in System Preferences to set them, and then go through the exact steps again to unset them. Too repetitive. I wish there is a way to set and unset proxies easily, but I cannot find one. I bit the bullet and use AppleScript (yuck) to do that, here’s the complete script (beware, this is my first AppleScript program):

I hate to use AppleScript as it simply plays back what a human does, and so the speed is slow, which takes about 5 seconds to finish. I tried to do that by shell script but I couldn’t find the right way to do so, having looked at the defaults command but seems it is not capable at what I want. Anybody knows?