Applescript - 如果应用程序不在前面,我如何影响应用程序的"main"窗口?



逻辑有一个"主窗口";这在技术上并不总是在前面(可以有更小的浮动窗口等(。所以我不能这样做:

tell application "System Events" to tell process "Logic Pro"
get value of UI element [xyz] of the front window
end tell

主窗口的名称不一致(根据保存项目的名称而更改(,所以我不能这样做:

tell application "System Events" to tell process "Logic Pro"
get value of UI element [xyz] of window "my project"
end tell

是否有某种方式可以始终如一地提及";主窗口";?

至少有两种方法:

  1. 检查窗口是否为主窗口

    tell application "System Events" to tell process "Logic Pro X"
    tell (first window whose value of attribute "AXMain" is true)
    -- do something
    end tell
    end tell
    
  2. 检查该窗口是否为文档窗口

    tell application "System Events" to tell process "Logic Pro X"
    tell (first window whose value of attribute "AXDocument" starts with "file://")
    -- do something
    end tell
    end tell
    

相关内容

  • 没有找到相关文章

最新更新