我正在尝试获取可见窗口列表,即桌面上显示的窗口,而不是最小化。
所以,我有这个脚本,它给了我正在运行的进程的最正确的列表,并有一个与之关联的窗口。但我无法获得与这些过程相关的可见窗口的id。
这是脚本:
set visibleWindows to ""
set message to ""
tell application "System Events"
set listOfProcesses to (name of every process where background only is false)
repeat with visibleProcess in listOfProcesses
try
tell process visibleProcess to set visibleWindows to visibleWindows & (id of windows whose visible is true)
on error someError
set message to "Some error occured :" & someError
end try
end repeat
end tell
return {visibleWindows, listOfProcesses, message}
你可以在脚本编辑器中尝试这个,但它总是给出一个空列表。
非常感谢任何帮助/建议。
答案 0 :(得分:0)
这个脚本运行得很好:
set windowsInDock to {}
tell application "System Events"
repeat with this_app in (get processes whose background only is false) --get applications with 1+ window
set windowsInDock to windowsInDock & (get windows of this_app whose value of its attribute "AXMinimized" is true)
end repeat
end tell
return windowsInDock
由jackjr300提供。