applescript - 使用 AppleScript 获取 Finder 打开的应用程序的 UI 元素
问题描述
set classNames to {}
tell application "Finder"
tell front window of (first application process whose frontmost is true)
set uiElems to entire contents as list
end tell
end tell
当我在脚本编辑器中运行它时,它返回:
{group 1 of window "test" of application process "Script Editor" of application "Finder", pop up button 1 of group 1 of window "test" of application process "Script Editor" of application "Finder", pop up button 2 of group 1 of window "test" of application process "Script Editor" of application "Finder", checkbox 1 of window "test" of application process "Script Editor" of application "Finder", checkbox 2 of window "test" of application process "Script Editor" of application "Finder", checkbox 3 of window "test" of application process "Script Editor" of application "Finder", busy indicator 1 of window "test" of application process "Script Editor" of application "Finder", static text "Running…" of window "test" of application process "Script Editor" of application "Finder", splitter group 1 of window "test" of application process "Script Editor" of application "Finder", splitter group 1 of splitter group 1 of window "test" of application process "Script Editor" of application "Finder", scroll area 1 of splitter group 1 of splitter group 1 of window "test" of application process "Script Editor" of application "Finder", text area 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "test" of application process "Script Editor" of application "Finder", scroll bar 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "test" of application process "Script Editor" of application "Finder", splitter 1 of splitter group 1 of splitter group 1 of window "test" of application process "Script Editor" of application "Finder", group 1 of splitter group 1 of splitter group 1 of window "test" of application process "Script Editor" of application "Finder", static text "Result" of group 1 of splitter group 1 of splitter group 1 of window "test" of application process "Script Editor" of application "Finder", scroll area 1 of group 1 of splitter group 1 of splitter group 1 of window "test" of application process "Script Editor" of application "Finder", text area 1 of scroll area 1 of group 1 of splitter group 1 of splitter group 1 of window "test" of application process "Script Editor" of application "Finder", scroll bar 1 of scroll area 1 of group 1 of splitter group 1 of splitter group 1 of window "test" of application process "Script Editor" of application "Finder", splitter 1 of splitter group 1 of window "test" of application process "Script Editor" of application "Finder", toolbar 1 of window "test" of application process "Script Editor" of application "Finder", button 1 of toolbar 1 of window "test" of application process "Script Editor" of application "Finder", button 2 of toolbar 1 of window "test" of application process "Script Editor" of application "Finder", button 3 of toolbar 1 of window "test" of application process "Script Editor" of application "Finder", button 4 of toolbar 1 of window "test" of application process "Script Editor" of application "Finder", group 1 of toolbar 1 of window "test" of application process "Script Editor" of application "Finder", group 1 of group 1 of toolbar 1 of window "test" of application process "Script Editor" of application "Finder", checkbox 1 of group 1 of group 1 of toolbar 1 of window "test" of application process "Script Editor" of application "Finder", checkbox 2 of group 1 of group 1 of toolbar 1 of window "test" of application process "Script Editor" of application "Finder", static text "—" of window "test" of application process "Script Editor" of application "Finder", button 1 of window "test" of application process "Script Editor" of application "Finder", button 2 of window "test" of application process "Script Editor" of application "Finder", button 3 of window "test" of application process "Script Editor" of application "Finder", menu button "Edited" of window "test" of application process "Script Editor" of application "Finder", image "test" of window "test" of application process "Script Editor" of application "Finder", static text "test" of window "test" of application process "Script Editor" of application "Finder"}
但是当我尝试将脚本作为应用程序运行并尝试通过 Finder 打开应用程序时,错误是:
无法获取最前面 = true 的应用程序进程 1 的窗口 1。无效索引。(-1719)
有人可以帮忙吗?我是 AppleScript 的新手,没有任何线索。
解决方案
推荐阅读
- java - 如何修复此错误:模块“packageName”生产:java.lang.ClassCastExcept
- java - 将可执行文件 (.exe) 嵌入 php
- c# - 如何从 excel 中读取数据并推入 asp.net 中的数组?
- android - 本地化后flutter在启动时显示黑屏
- electron - 无法加载资源:电子中的 net::ERR_FILE_NOT_FOUND
- python - ImageField 的默认图像
- java - 是否有任何排序集不允许添加等于元素并让它们按预定义的比较器排序?
- security - Keycloak 授权 - 最佳实践角色与组
- javascript - 如何使用 JavaScript 一次将内部文本放置到相同的多个 td 中?
- android - 使用 ARCore 在 android 中创建 3d 盒子模型