我试图获取其文档名称为#34; book.pdf"的窗口。这是我的方法
tell application "Preview"
set w to every window whose document is named "book.pdf"
end
这不起作用。我尝试了大约100个排列,但我没有到达任何地方。有什么提示吗?
答案 0 :(得分:0)
您可以将AXTitle
与contains
结合使用,并告诉System Events
而不是Preview
注意我将它包装在try
块中,因为如果找不到字符串匹配,myWindow将是未定义的。
set n to "book.pdf" -- whatever substring you want to find
tell application "System Events" to tell process "Preview"
try
set myWindow to (1st window whose value of attribute "AXMain" is true and value of attribute "AXTitle" contains n)
log myWindow
on error
log "not found"
end try
end tell