Listando todas as janelas de todos os aplicativos
Eu estou tentando escrever um script applescript que redimensiona todas as janelas abertas. Para ter certeza de que estou acessando todas as janelas, estou fazendo meu script informar o nome do aplicativo e o número de janelas abertas desse aplicativo.
Curiosamente, enquanto ouço os nomes de todos os meus aplicativos abertos, meu script diz que todos eles têm 0 janelas abertas. Como posso corrigir esse problema?
Aqui está meu código:
tell application "System Events"
repeat with theProcess in (every process)
if background only of theProcess is false then
if name of theProcess is not "Finder" then
if name of theProcess is "Google Chrome" then
say "Chrome woo hoo"
say (count windows as string)
else
say name of theProcess as string
say (count windows as string)
tell theProcess
repeat with theWindow in windows
say "found a window of"
say (name of theProcess) as string
tell theWindow
click button 2
end tell
end repeat
end tell
end if
end if
end if
end repeat
end tell
Estou no Mac OS X 10.7.5, usando o automator 2.2.4 para gravar / executar este applescript