使用 Applescript 更改没有标题的复选框的值

发布于 2024-12-05 02:18:47 字数 753 浏览 0 评论 0原文

我尝试制作一个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 代理”和“安全 Web 代理”设置的值,因为它们没有辅助功能检查器显示的标题。

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千里故人稀 2024-12-12 02:18:47

/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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文