1

I use Mac OS X 10.10 and I would like to write a program that looks continuously for a window analyzing all the names of the opened windows. When the windows appear, I would like that the program will look for a button with a specific label and once found it, the app should send it a "pressed message". I would be able to do it under windows, but I am not so familiar with Mac. I have found a question related to mine (How do I get a list of the window titles on the Mac OSX?), but I think the most difficult part is finding the button and sending it a "pressed message".

Thank you in advance!

Community
  • 1
  • 1
Nisba
  • 3,210
  • 2
  • 27
  • 46

1 Answers1

0

What you are looking for is the Accessibilty APIs. These are mostly Core Foundation style C APIs and typically prefixed with AX. You might also want to consider additional identifiers beyond window title as window titles are not necessarily unique.

Using the AX APIs is not easy and is extremely verbose. You can use them to explore the UI and find things and interact with them but you might have more limited success observing user interaction. That might require a more fragile combination with event monitoring using NSEvent globalMonitor or CGEventTap depending on the UI widgets involved.

Also note that using the AX APIs to control anything outside your app is not sandbox capable.

uchuugaka
  • 12,679
  • 6
  • 37
  • 55
  • Although I should note, your app can control other things if the user manually enables it by adding your app to the security preferences. There's not a great way to do this programatically and sandbox compliant – uchuugaka Jun 13 '15 at 22:09