You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:macOS Big Sur中脚本无法访问popover UI元素,与Ventura存在差异

macOS Ventura与Big Sur下AppleScript获取UI元素差异排查

测试脚本

tell process "EdgeMonitor"
    tell menu bar 2        
        UI elements      
    end tell
end tell

问题现象

同一脚本在不同macOS版本下执行,获取到的EdgeMonitor应用UI元素存在差异:

  • macOS Ventura 识别结果:
    menu bar item 1 of menu bar 2 of application process "EdgeMonitor" of application "System Events", pop over 1 of menu bar 2 of application process "EdgeMonitor" of application "System Events"
  • macOS Big Sur 识别结果:
    menu bar item 1 of menu bar 2 of application process "EdgeMonitor" of application "System Events", menu bar item 2 of menu bar 2 of application process "EdgeMonitor" of application "System Events"

需要访问的popover元素在Ventura中可被直接识别,但在Big Sur中完全无法被检测到。

可能原因及排查方向

  1. Accessibility API 版本差异
    macOS Ventura对辅助功能框架进行了更新,UI元素的暴露规则发生变化。Big Sur的Accessibility API可能不会将popover直接作为menu bar的子元素暴露,而是将其嵌套在对应的menu bar item层级下。

  2. 应用UI适配逻辑不同
    EdgeMonitor可能针对不同macOS版本做了UI实现分支:在Ventura中popover被挂载到menu bar层级,而在Big Sur中则属于menu bar item的子元素。

  3. 系统权限校验差异
    不同版本macOS的辅助功能权限校验逻辑存在区别,需确认Big Sur下是否已完全授予脚本或相关应用的辅助功能访问权限。

排查建议

  • 尝试遍历menu bar item的子元素,检查popover是否被嵌套其中:
    tell process "EdgeMonitor"
        tell menu bar 2
            tell menu bar item 1
                UI elements
            end tell
        end tell
    end tell
    
  • 使用系统自带的Accessibility Inspector工具,分别在两个系统中查看EdgeMonitor的UI层级结构,确认popover的实际位置。
  • 检查EdgeMonitor的版本日志,确认是否存在针对不同macOS版本的UI层级调整。

内容的提问来源于stack exchange,提问作者Vidit Kothari

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 01:53:23