AppleScript获取窗口的标题

时间:2015-10-29 17:26:19

标签: windows applescript title

我尝试获取应用的标题(并将其复制为var) 到目前为止,这是我的代码,但这是失败的

tell application "app"
    activate
end tell

tell application "System Events"
    set frontApp to name of first application process whose frontmost is true
end tell

tell application frontApp
    if the (count of windows) is not 0 then
        set window_name to name of front window
    end if
end tell

结果:

  

错误"应用程序出错:每个窗口都不理解“计数”消息。"每个窗口的数字为-1708

1 个答案:

答案 0 :(得分:2)

错误消息表明最前面的应用程序不是可编写脚本的

定位不可编写脚本的应用程序窗口的唯一方法是通过[application] process上下文中的System Events个对象的属性 - 而不是通过其{{ 1}} object(只有可编写脚本的 application个对象有application个元素):

windows
相关问题