使用 Apple 脚本取消选择默认屏幕截图选项

发布于 2024-10-23 14:04:15 字数 147 浏览 5 评论 0原文

我正在尝试制作一个苹果脚本,通过它我可以取消选择此选项:“

系统偏好设置”>“硬件>键盘>键盘快捷键>屏幕截图>将所选区域的图片保存为文件

有人可以建议我一些示例脚本吗?

谢谢,

米拉杰

I am trying to make an apple script through which I can deselect this option:

System Preferences > Hardware > Keyboard > Keyboard Shortcuts > Screen Shots > Save picture of selected area as a file

Can anyone suggest me some sample script for it?

Thanks,

Miraaj

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

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

发布评论

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

评论(2

ζ澈沫 2024-10-30 14:04:15

默认情况下,系统首选项不可编写脚本。您将必须使用 GUI 脚本,但这对每个人来说都会有点不同,具体取决于他们安装的首选项。 www.macosxautomation.com 上有一个很好的示例,可以帮助您开始了。

System Preferences are not scriptable by default. You will have to use GUI Scripting, but that will be a little bit different for everyone depending on what preferences they have installed. There is a an excellent example over at www.macosxautomation.com that will get you started.

遗忘曾经 2024-10-30 14:04:15

我对此有点晚了,但是,这对我有用:

     tell application "System Preferences"
       --activate
       reveal anchor "shortcutsTab" of pane id "com.apple.preference.keyboard"
     end tell

     tell application "System Events" to tell process "System Preferences"
        select row 4 of table 1 of scroll area 1 of splitter group 1 of tab group 1 of window 1
        repeat with r in rows of outline 1 of scroll area 2 of splitter group 1 of tab group 1 of window 1
          click checkbox 1 of UI element 1 of r
        end repeat
     end tell

     quit application "System Preferences"

请注意,这会禁用所有复选框,而不仅仅是“将选定区域的图片保存为文件”。要仅禁用该功能,请将重复块替换为:

click checkbox 1 of UI element 1 of row 4 of outline 1 of scroll area 2 of splitter group 1 of tab group 1 of window 1

您可以通过将 row 4 替换为正确快捷方式的行号来启用或禁用任何其他屏幕截图快捷方式

I am a bit late to this but, here's what worked for me:

     tell application "System Preferences"
       --activate
       reveal anchor "shortcutsTab" of pane id "com.apple.preference.keyboard"
     end tell

     tell application "System Events" to tell process "System Preferences"
        select row 4 of table 1 of scroll area 1 of splitter group 1 of tab group 1 of window 1
        repeat with r in rows of outline 1 of scroll area 2 of splitter group 1 of tab group 1 of window 1
          click checkbox 1 of UI element 1 of r
        end repeat
     end tell

     quit application "System Preferences"

Note this disable all checkboxes and not just "Save picture of selected area as a file". To disable just that replace the repeat block with:

click checkbox 1 of UI element 1 of row 4 of outline 1 of scroll area 2 of splitter group 1 of tab group 1 of window 1

You can enable or disable any other screenshot shortcut by replacing row 4 with the row number of the correct shortcut

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