kAXErrorCannotComplete

When I call the AXUIElementGetAttributeValueCount function, I get the kAXErrorCannotComplete error. Please advise.


The following is the relevant code



ProcessSerialNumber psn = {

0,kNoProcess

};

Boolean findProcess = NO;

int ncount = 0;



do{

while (noErr == GetNextProcess(&psn)) {

CFStringRef name = NULL;

CopyProcessName(&psn, &name);

NSString *appName = [[NSString alloc]initWithFormat:@"%@",name];

if ([appName isEqualToString:@"mainApp"]) {

findProcess = YES;

break;

}

}

if (findProcess == YES) {

break;

}


}while (ncount++ < 3);



if (findProcess)

{


pid_t pid;

GetProcessPID(&psn, &pid);


NSLog(@"-%d-",pid);


AXUIElementRef element = AXUIElementCreateApplication(pid);


Boolean isTrusted = AXIsProcessTrustedWithOptions(CFDictionaryCreate(NULL, (const void*[]) { kAXTrustedCheckOptionPrompt }, (const void*[]){ kCFBooleanTrue }, 1, NULL, NULL));


if (isTrusted)

{

NSLog(@"the API Enabled");

CFIndex count = 0;


AXError sExx = AXUIElementGetAttributeValueCount(element, kAXWindowsAttribute, &count);


NSLog("%d",sExx); //the AXError is -25204 kAXErrorCannotComplete

}

}

Replies

Same issue here, can someone from Apple please advise, same issue here - trying to create an accessibility assitance application and blocked by this!


Platform info:

Running macOS high sierra - 10.13.6

Xcode 9.4.1


Please let me know if you need more info.