Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 233
shoumikhin Avatar asked Jun 14 '10 18:06

shoumikhin


People also ask

How do you switch between applications on a Mac?

Quickly switch between app windows On your Mac, do any of the following: Switch to the previous app: Press Command-Tab. Scroll through all open apps: Press and hold the Command key, press the Tab key, then press the Left or Right arrow key until you get to the app you want.


2 Answers

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.

like image 186
Scott Giese Avatar answered Sep 16 '22 17:09

Scott Giese


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
like image 34
Leibowitzn Avatar answered Sep 20 '22 17:09

Leibowitzn