Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Is there a tool to count the number of windows I have open, including on all Spaces?

I am curious and too lazy to do it manually. :)

share|improve this question

1 Answer 1

I guess this AppleScript should do:

set numberOfWindows to "0"

tell application "System Events"
    set allProcesses to application processes
    repeat with i from 1 to number of allProcesses
        tell process i
            set numberOfWindows to (numberOfWindows + (count windows))
        end tell
    end repeat
end tell
share|improve this answer
1  
Lol: tell app "System Events" to count windows of processes –  ؘؘؘ Mar 3 '11 at 6:27
    
@l-ri I made my statement deliberately more verbose, given that other users usually want to incorporate more than just a count of all processes´ windows and thus might learn more this way - but true, your version is shorter. Don´t get how your Lol is supposed to be helpful, though. –  Asmus Mar 3 '11 at 10:14
    
OK, so I paste that into the AppleScript editor and I get: 'error "System Events got an error: Access for assistive devices is disabled."' How do I enable it? For applications that I've installed previously that needed this, the app itself prompts me. "Enable access for assistive devices" is enabled in my system preferences. –  Reid Mar 3 '11 at 19:15
    
You can check whether it´s enabled by running tell application "System Events" to get UI elements enabled. You can enable it by adding tell application "System Events" to set UI elements enabled to true in the beginning of the script; though it seems strange for me, that it seems to be already enabled in your case. –  Asmus Mar 3 '11 at 20:20
1  
OK, so tell application "System Events" to get UI elements enabled returns true, but the error above still happens, even with adding the enabler line you suggest to the beginning. –  Reid Mar 7 '11 at 21:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.