Wyświetlanie wszystkich okien wszystkich aplikacji

Próbuję napisać skrypt applescript, który zmienia rozmiar wszystkich otwartych okien. Aby upewnić się, że docieram do wszystkich okien, robię skrypt wypowiadający nazwę aplikacji oraz liczbę otwartych okien tej aplikacji.
Co ciekawe, podczas gdy słyszę nazwy wszystkich moich otwartych aplikacji, mój skrypt mówi, że wszystkie mają otwarte 0 okien. Jak mogę rozwiązać ten problem?

Oto mój kod:

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

Jestem na Mac OS X 10.7.5, używając automatora 2.2.4 do napisania / uruchomienia tego AppleScript

questionAnswers(2)

yourAnswerToTheQuestion