1

我尝试制作 Applescript 以启用系统偏好设置中“网络”设置的“高级..”菜单中的“Web 代理”和“安全 Web 代理”选项。

到目前为止,这是我的applescript..

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

我无法更改“Web Proxy”和“Secure Web Proxy”设置的值,因为它们没有 Accessibility Inspector 显示的标题。

有没有其他方法可以使用类似于我上面尝试过的 Applescript 启用/禁用复选框?

4

1 回答 1

0

在 /usr/sbin/networksetup 中有一个名为“networksetup”的命令行工具。我没怎么用过它,但是查看它的手册页有几件关于代理的事情。这是我看到的一对...

[-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]

所以使用这些的“do shell script”命令应该可以完成这项工作。不幸的是,我无法为您提供特定命令,但祝您好运。

顺便说一句,在手册页的示例中,它显示了这些......

networksetup -setwebproxy "Built-in Ethernet" proxy.company.com 80
networksetup -setwebproxy "Built-In Ethernet" proxy.company.com 80 On authusername authpassword
于 2011-09-18T10:05:33.050 回答