我编写了以下代码片段来获取 Firefox 窗口的标题,
tell application "Firefox"
set window_name to name of front window
display dialog window_name
end tell
它运行良好,但是当我将 firefox 更改为 adobe 时,出现以下错误
“Adobe Reader 出现错误:无法获取窗口 1 的名称。”
任何人都知道如何获得窗口标题?
我编写了以下代码片段来获取 Firefox 窗口的标题,
tell application "Firefox"
set window_name to name of front window
display dialog window_name
end tell
它运行良好,但是当我将 firefox 更改为 adobe 时,出现以下错误
“Adobe Reader 出现错误:无法获取窗口 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 可以做的所有事情,有时甚至更多。如果你有问题,就问吧。:)