I have a long-lost question about my application clicks and control of other applications. I use AXUIElement to implement this feature, but I have tried it for a long time, using OC before Mac OS 10.8 is achievable, but after 10.9 return AXError -25204, Please help me to see why.Thanks & Best Regards
OC Code:
AXUIElementRef element = AXUIElementCreateApplication(537);//537 is a running app's pid
CFTypeRef frontWindow;
AXError err = AXUIElementCopyAttributeValue(element, kAXWindowsAttribute,&frontWindow);
NSLog(@"%d %@",err,frontWindow); //-25204 (null)
CFArrayRef names;
AXError err1 = AXUIElementCopyAttributeNames(element, &names);
NSLog(@"%d %@",err1,names); //-25204 (null)
CFIndex count = 0;
AXError err2 = AXUIElementGetAttributeValueCount(element, kAXChildrenAttribute, &count);
NSLog(@"%d %ld",err2,(long)count);//-25204 0
Swift Code:
let appRef = AXUIElementCreateApplication(569) //569 is a running app's pid
var count : CFIndex = 0
let err = AXUIElementGetAttributeValueCount(appRef, kAXWindowsAttribute as CFString, &count)
print(err.rawValue) //err.rawValue return -25204