Question

I have an AXObserver registered like so:

 AXObserverCreate(pid, axObserverCallback, &_observer);

This is the callback method:

static void axObserverCallback(AXObserverRef observer, AXUIElementRef elementRef, CFStringRef notification, void *self) { .. }

And this is how I add a notification:

        AXObserverAddNotification(_observer, app, kAXFocusedWindowChangedNotification, self);

What I'm noticing is that the element added to the observer (for notifying) (in the above case "app") does not seem to correspond to the one set in the observer callback ("elementRef"). It looks like it's a copy? At least I can't compare them with == and if I NSLog them they show a different address.

Is there any way to compare AXUIElementRefs that are copies? (And is this the normal behavior to return a copy instead of the original?)

Was it helpful?

Solution

Like all Core Foundation objects, AXUIElementRefs should be compared using CFEqual(), not by checking pointer equality.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top