我编写了以下代码片段来获取firefox窗口的标题,
tell application "Firefox"
set window_name to name of front window
display dialog window_name
end tell
它运行良好,但是当我将firefox更改为adobe时,我收到以下错误
“Adobe Reader出错:无法获取窗口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可以执行的所有操作,有时甚至更多。如果你有问题,就问吧。 :)