Mac - List opened windows in terminal

Tokytok picture Tokytok · Apr 12, 2012 · Viewed 8k times · Source

I want to list opened windows in the terminal to get x, y, width and height like xwininfo -root -tree for X11.

I tried:

osacript -e tell application "Microsoft Word" to get the bounds of the front window

But it's does not work for all Application and you can't specify a child (If you have two Word Document, it return the first opened).

Answer

strkol picture strkol · Apr 12, 2012

To get the position of all windows:

osascript -e 'tell application "System Events" to get the position of every window of every process'

The size:

osascript -e 'tell application "System Events" to get the size of every window of every process'

The title:

osascript -e 'tell application "System Events" to get the title of every window of every process'

Check the reference in AppleScript Editor for more properties.