8

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).

Mat
  • 202,337
  • 40
  • 393
  • 406
Tokytok
  • 298
  • 2
  • 6
  • 14

1 Answers1

9

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.

strkol
  • 1,909
  • 15
  • 11
  • 5
    Thanks but it does not work. When I try : osascript -e 'tell application "System Events" to get the position of every window of every process' I have this error : execution error: System Events got an error: Access for assistive devices is disabled. (-25211) – Tokytok Apr 12 '12 at 14:15
  • 2
    go to system preferences -> universal access and enable "Enable access for assistive devices" – strkol Apr 12 '12 at 14:22
  • 3
    Thanks a lot! Last question, how I can determine if the window is in the dock (hidden) or on the front ? – Tokytok Apr 12 '12 at 14:46
  • 1
    I found I also had to restart my terminal (iTerm) for permission to be granted (Big Sur) – jameshfisher Dec 15 '20 at 11:29