在applescript中获取当前的adobe reader窗口标题

时间:2011-08-01 15:48:08

标签: applescript adobe-reader

我编写了以下代码片段来获取firefox窗口的标题,

tell application "Firefox"
    set window_name to name of front window
    display dialog window_name

end tell

它运行良好,但是当我将firefox更改为adobe时,我收到以下错误

“Adobe Reader出错:无法获取窗口1的名称。”

任何人都知道如何获得窗口标题?

1 个答案:

答案 0 :(得分:1)

你在问题​​中写了答案!

tell application "System Events" to set adobe_windows to (get the title of every window of every process whose name contains "Adobe") as list
set prevTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to {", "}
set adobe_windows to adobe_windows as string
display dialog adobe_windows
set AppleScript's text item delimiters to prevTIDs

当我收到有关窗口标题的错误时,我会前往System Events寻求帮助。这甚至适用于Finder! System Events可以完成Finder可以执行的所有操作,有时甚至更多。如果你有问题,就问吧。 :)