AXSwift icon indicating copy to clipboard operation
AXSwift copied to clipboard

Check for isFinishedLaunching when initializing an Application from NSRunningApplication

Open undsoft opened this issue 5 years ago • 1 comments

In my app I'm listening to didActivateApplicationNotification notifications and then add AXObserver to the app that was activated. I've noticed that in some scenarios I got UnknownUIElement errors when I was trying to add an observable right after launching Chrome. I think this is due to the fact that chrome has isFinishedLaunching = false when activated.

The solution for me is to listen for another additional event (didLaunchApplicationNotification), but you may want to consider adding a check for isFinishedLaunching in Application initializers.

undsoft avatar Apr 02 '19 14:04 undsoft

Thanks, I'll consider it. I don't know if that behavior is documented anywhere so I can verify I'm doing the right thing, but that's true for a lot of aspects of these APIs.

If initialized with only a process ID, we should document that we don't check this, either.

tmandry avatar Apr 13 '19 03:04 tmandry