How to get another application window's title, position and size in Mac OS without Accessibility API?
Asked Answered
N

2

8

How can I get window's title, position and size if it does not support Accessibility API? Accessibility Inspector does not see it at all. Say, it's a xterm window in X11.app (X11->Applications->Terminal).

Nutpick answered 14/6, 2010 at 18:13 Comment(1)
Do you know where can actually download Accessibility Inspector from? I hate how pages on Apple site keep moving and disappearing.Outhouse
B
11

You should be able to get all of this window information through the methods exposed in the CGWindow.h header file. Apple's docs are online on the Quartz Window Services Reference page. They also have a very informative sample app called Son of Grab which should get you started.

Brooch answered 15/6, 2010 at 3:7 Comment(0)
S
2

You can use CGWindowListCreateDescriptionFromArray(). See CGWindow.h

This gives you an array of dictionaries. The following information will probably be useful to you:

  • position and size: kCGWindowBounds
  • name: kCGWindowName
Slighting answered 15/6, 2010 at 18:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.