How to Use AXObserverAddNotification
How to Use AXObserverAddNotification
- Subject: How to Use AXObserverAddNotification
- From: James Lee <email@hidden>
- Date: Fri, 20 Jul 2018 06:26:43 -0400
Hi All,
I'm having a problem getting AXObserverAddNotification to work in Swift
4. The testing code below compiles and runs without an error, but
callBack doesn't seem to get executed when I change main window.
Here is also my Stack Overflow post.
https://stackoverflow.com/questions/48825816/how-to-use-axobserveraddnotification-in-swift
Could someone please help with this? I'd really appreciate it.
Thank you so much for your help in advance!
func observe(app:pid_t, element:AXUIElement) {
var observer: AXObserver? = nil
func callBack(observer: AXObserver?, element: AXUIElement?,
notification: CFString, refcon: UnsafeMutableRawPointer?) {
print(notification)
}
if AXObserverCreate(app, callBack, &observer) == .success {
CFRunLoopAddSource(CFRunLoopGetCurrent(),
AXObserverGetRunLoopSource(observer!), .defaultMode)
if AXObserverAddNotification(observer!, element,
kAXMainWindowChangedNotification as CFString,
UnsafeMutableRawPointer(Unmanaged.passRetained(self).toOpaque())) ==
.success {
print("Watching \(element.value(of:"AXTitle"))")
}
}
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Accessibility-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden