1

I tried to make an Applescript to enable the "Web Proxy" and "Secure Web Proxy" option in the "advanced.." menu of the "Network" settings in System Preferences.

Here's my applescript so far..

tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.network"
end tell

tell application "System Events"
tell application process "System Preferences"
    tell window "Network"
        click button "Advanced…"
        tell tab group 1 of sheet 1
            click radio button "Proxies"
            tell group 1
                //what to do here to change Web Proxy and Secure Web Proxy Checkboxes?
            end tell
        end tell
    end tell
end tell
end tell

I cannot change the value of the "Web Proxy" and "Secure Web Proxy" settings because, they have no title as shown by Accessibility Inspector.

Is there any other way to enable/disable the checkboxes using an Applescript similar to the one I have tried above?

meh
  • 43
  • 1
  • 5

1 Answers1

0

There is a command line tool called "networksetup" at /usr/sbin/networksetup. I haven't used it much but looking at the man page for it there are several things regarding proxies. Here's a couple I see...

[-getwebproxy networkservice]
[-setwebproxy networkservice domain portnumber authenticated username password]
[-setwebproxystate networkservice on | off]
[-getsecurewebproxy networkservice]
[-setsecurewebproxy networkservice domain portnumber authenticated username password]
[-setsecurewebproxystate networkservice on | off]

So a "do shell script" command using these should do the job. Unfortunately I can't help you with the specific commands but good luck.

By the way, down in the examples on the man page it shows these...

networksetup -setwebproxy "Built-in Ethernet" proxy.company.com 80
networksetup -setwebproxy "Built-In Ethernet" proxy.company.com 80 On authusername authpassword
regulus6633
  • 18,848
  • 5
  • 41
  • 49
  • If I can put it this way, here's my problem description: An applescript to automatically enable the Web Proxy and Secure Web Proxy settings. While I appreciate your insight into using a shell script to do the trick, I'd love to satisfy my thirst to get this done using applescript! – meh Sep 21 '11 at 16:54
  • Well even if they don't have a name you can probably access them by number... just like you did with several of the other commands... so give that a try. Bottom line is use the name or number, either works if it's possible. – regulus6633 Sep 21 '11 at 20:43
  • RE: "my thirst to get this done using applescript" -- 'do shell script' IS AppleScript, even though it does its work by using a system command. I'd say its just as 'pure' to use 'do shell script' as it is to use System Events. – Ron Reuter May 04 '16 at 03:09