2

I am trying to build an application which creates and closes it's window when a particular window of another 3rd party application is created or closed. Any pointers or sample code on how to achieve this will be of great help. On window I achieved the same thing with the help of SetWinEventHook, by registering for events AccessibleEvents.Create and AccessibleEvents.Delete and then checking for that window class name inside event handler .

Swapnil
  • 121
  • 1
  • 4

1 Answers1

0

You can obtain a list of all windows on OS X via CGWindowListCopyWindowInfo(), and if you know the specifics of the target window, you can monitor that window's visibility and show/hide your app's window based on that. For working with these CGWindow* calls you may want to check out the Apple SonOfGrab example code.

Alternatively if your users enable Accessibility support for your app, you can obtain information about other process windows on the screen as well.

It's worth pointing out that both of these approaches are somewhat fragile, in that if the target application changes in the future your app may not behave properly when attempting to find it on screen.

Matt R
  • 81
  • 1
  • 3
  • Thanks Matt R .. I saw the Son of Grab code and it makes lot of sense. So that means that application will have to keep on polling all the windows on the screen unlike windows where event is notified to the application? – Swapnil Apr 07 '16 at 15:29