Posts

Post not yet marked as solved
0 Replies
327 Views
I am trying to use NSAccessibility API to query the content UI element. For example the string from Safari URL Text FieldI have been experimenting AXUIElementRef APII have a Test Application1: monitoring NSWorkspaceDidLaunchApplicationNotification>> NSWorkspace *workspace = [NSWorkspace sharedWorkspace]; /* Register for application launch notifications */ [[workspace notificationCenter] addObserver:self selector:@selector(applicationLaunched:) name:NSWorkspaceDidLaunchApplicationNotification object:workspace];>>2:In the applicationLaunched selector2.1:It checksNSApplicationBundleIdentifier = "com.apple.Safari";2.2:Then it usesNSNumber *pidNumber =[[notification userInfo] valueForKey:@"NSApplicationProcessIdentifier"];to get pid.2.3:Next, from the pid, it usesAXUIElementRef element = AXUIElementCreateApplication(pid);to get an AXUIElementRef2.4:When I trying to copy out the attribute from the AXUIElementRef elementi.e. CFArrayRef arrayRefSys; AXError e = AXUIElementCopyAttributeNames(element, &arrayRefSys);I always get kAXErrorCannotComplete error.P.S.:And I validated from NSDictionary *options = @{(__bridge id) kAXTrustedCheckOptionPrompt : @YES}; BOOL accessibilityEnabled = AXIsProcessTrustedWithOptions((__bridge CFDictionaryRef) options);I could confirm that accessibilityEnabled is YES in my test App.I wonder if someone happen to familiar with this topic?Thanks.
Posted
by longst.
Last updated
.