button - Applescript Mojave 单击图像捕获按钮
问题描述
Applescript 如何在 Mojave Image Capture 中单击“删除”按钮?
在 ML 中,这有效——
activate application "Image Capture"
tell application "System Events"
click button 3 of group 1 of splitter group 1 of window "Image Capture" of application process "Image Capture" of application "System Events"
end tell
- 我还没有得到莫哈韦的等价物。谢谢你。
解决方案
他们移动了一些东西。尝试这个:
tell application "System Events"
tell process "Image Capture"
set frontmost to true
click window "Image Capture"'s splitter group 1's group 2's button "Delete"
key code 48 -- tab to move focus to 'delete'
-- key code 36 -- return key
end tell
end tell
我添加了清除“你确定吗?”的代码。对话框并自动删除图像,但我注释掉了模拟返回键的“key code 36”行,因为我不想让你不小心删除一些重要的东西。
调试 GUI 脚本
如果上面的代码抛出错误,并且您没有 UIElementExplorer 或 UIBrowser(通过 GUI 向下钻取的应用程序),您可以在脚本编辑器中运行以下代码来调试它:
tell application "System Events"
tell process "Image Capture"
tell window "Image Capture"
tell splitter group 1
entire contents
end tell
end tell
end tell
end tell
这很慢,并且会在脚本日志中产生大量文本,从头到尾显示 GUI 的每个元素splitter group 1
。在日志中搜索“删除”,如下图所示:单击日志按钮(绿色圆圈),键入 command-F 并输入术语“删除”(红色圆圈),它将显示条目对于删除按钮。然后只需将该路径复制到代码中。
您可能需要改变焦点(即把entire contents
线放在线之后window "Image Capture"
以获得更宽的范围)。
请注意,当您添加不同的设备并以不同的模式浏览时,GUI 可能会发生变化,并且当 GUI 更改所有索引时(拆分器组 1、组 2、按钮 7)也可能会更改。如果您使用多个设备来查看发生了什么,您可能需要使用几种不同的配置对此进行测试。
推荐阅读
- javascript - 如何在javascript中过滤json?
- java - 在 MVC 应用程序中对日志消息进行分组的最佳方法是什么
- python - 使用 Python 创建扩展函数
- jms - 只读 JMS 主题订阅?(或在出队时保留 JMS 消息)
- javascript - 无法冻结 GridView 标头
- javascript - 如何设置 MUI 概述的 TextField 的边框?
- c - 互斥文件读取同步
- heroku - PWA 不根据 manifest.json 显示自定义图标(Heroku 上的 Node.js)
- webpack - Laravel Mix LESS 编译在 Google 字体导入时失败
- javascript - 在 Chrome 中,我如何设置一个 cookie 的 max-age 小于 213 天?