0

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?

Swapnil
  • 121
  • 1
  • 4
  • You can see https://kotikan.com/blog/item/passing-data-between-ios-apps – jose920405 Apr 13 '16 at 20:22
  • Possible duplicate of [How to pass text to 3rd party app in iOS](http://stackoverflow.com/questions/27861946/how-to-pass-text-to-3rd-party-app-in-ios) – jose920405 Apr 13 '16 at 20:22
  • The best way to do this is with Applescript or Javascript. Javascript support his much newer. Look here ; https://github.com/dtinth/JXA-Cookbook/wiki – john elemans Apr 13 '16 at 20:42
  • You might be able to do this with the Accessibility API but your app needs permission from the user. Search for `AXUIElementSetAttributeValue`. – Willeke Apr 13 '16 at 21:52

0 Answers0