How to get the window id with title of every process

applescript

I'm using the following simple script:

tell application "System Events" to get the title of every window of every process

Which works by printing titles of every window.

tell application "System Events" to get the id of every window of every process

The above script prints missing value

{{}, {}, {}, {}, {}, {}, {missing value, missing value}, {}, {missing value}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {missing value, missing value}, {missing value}, {}, {}, {missing value, missing value}, {missing value}, {missing value, missing value}, {}, {}, {}, {}, {}, {}, {}, {}}

How can I get the window id of every window?

Is it possible to get the window id and window title at a time?

Best Answer

Yes, you can get the window id and window title at the same time:

tell application "System Events" to get the {title, id} of every window of every process

However, many/most processes are invisible ones, so you'll want to reduce your list:

tell application "System Events" to get the {title, id} of every window of (every process whose visible is true)

And further, id is not something set in most windows. Perhaps you can say more about what you're trying to accomplish. You can examine the potential window properties with:

tell application "System Events" to get the properties of every window of (every process whose visible is true)