I can get a count of Firefox windows in the current Space, including any minimized windows (from any Space - what odd semantics) using something like this:
tell application "System Events"
count of windows of process "Firefox"
end tell
... and I can get a count of any minimized windows (from any application/space) with this:
tell application "System Events" to tell process "Dock"
count (UI elements of list 1 where role description is "minimized window dock item")
end tell
I cannot, however, figure out how to assemble a count of:
- non-minimized windows,
- for a specific application,
- on the current Space.