【问题标题】:Unnamed Window in ApplescriptApplescript中的未命名窗口
【发布时间】:2012-06-12 13:40:09
【问题描述】:

我正在使用 UI 脚本编写带有 applescript 的 iTunes 脚本。根据我在做什么,会出现 iTunes 通知,此时我需要处理它。窗口的名称是 AXWindow:"",我无法让 applescript 处理它。我尝试使用文字“”,尝试将变量定义为“”,尝试使用转义字符的两种情况,并尝试获取最前面进程的名称。

tell application "System Events"
     set processName to name of front window
end tell
tell button "whatever" of window processName
     click
end tell

但这会出现“错误“系统事件出错:无法获取窗口 1。无效索引。”任何对此的帮助将不胜感激。

【问题讨论】:

    标签: user-interface scripting window applescript itunes


    【解决方案1】:

    你可以这样做:

    tell application "iTunes" to activate
    tell application "System Events"
        tell process "iTunes"
            set xxx to first UI element whose role description is "dialog"
        end tell
    end tell
    

    或者全部找到:

    tell application "iTunes" to activate
    tell application "System Events"
        tell process "iTunes"
            set xxx to every UI element
        end tell
    end tell
    

    【讨论】:

      【解决方案2】:

      嗯,通常通知或用户对话框将显示为最前面的窗口,并保持在同一应用程序的其他窗口的顶部,直到用户(或脚本)单击某些内容。

      因此,对话窗口(如果有的话)应该可以通过说明符window 1 访问。然后,您可以通过阅读其属性进一步检查这是否真的是您感兴趣的窗口:

      tell application "System Events" to tell application process "iTunes"
        properties of window 1
      end tell
      

      【讨论】:

      • 我也有同样的想法,但我收到一个错误消息,告诉我窗口 1 无效
      猜你喜欢
      • 2010-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-29
      相关资源
      最近更新 更多