开发者

Change the value of a Checkbox with no Title using Applescript

开发者 https://www.devze.com 2023-04-05 10:54 出处:网络
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.

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 Pro开发者_如何学Pythonxy" 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?


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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号