I am building a cocoa application on Mac. Is it possible to 1) Bring 3rd party application window to focus. 2) Position the cursor into the text box of 3rd party application window? 3) Insert text into the text box.
Edit:- I tried to achieve this using AXUIElementSetAttributeValue but I am unable to make it work. Getting the corresponding AXUIElement works but after setting the text, changes are not visible in text box. I tried using the accessibility inspector to grab the details of the control. The control is of type "AXWebArea". Here is the code.
NSString *newTextStr = @"Hi!";
AXUIElementSetAttributeValue(windRef, kAXFocusedAttribute, kCFBooleanTrue);
AXError status = AXUIElementSetAttributeValue(windRef, kAXValueAttribute, (__bridge CFTypeRef)(newTextStr));
if (status != kAXErrorSuccess) {
NSLog(@"AXUIElementSetAttributeValue failed");
}
AXUIElementPerformAction(windRef, kAXConfirmAction);
Can somebody help me with this?