macOS accessibility API on WebKit applications with AXTextMarker

后端 未结 3 1279
没有蜡笔的小新
没有蜡笔的小新 2021-01-16 07:18

I need to access data from webkit applications such as Safari, Mail and maybe others. I can see in the Accessibility Inspector there is :AXTextMarker

3条回答
  •  星月不相逢
    2021-01-16 07:57

    Try this, I haven't tested this but I found some research on the API and I think this may solve your problem.

    It seems for the accessibility API to fully work the application needs to be trusted or basically have root access. Is the application running in root?

    I found some apple script from a past project. seemed relevant

    NSDictionary *errorInfo = [NSDictionary new];
    NSString *script =  [NSString stringWithFormat:@"do shell script \"%@ %@\" with administrator privileges", @"/usr/sbin/lsof",@"-c filecoord"];
    NSLog(@"Running... %@",script);
    NSAppleScript *appleScript = [[NSAppleScript new] initWithSource:script];
    NSAppleEventDescriptor * eventResult = [appleScript executeAndReturnError:&errorInfo];
    

    This apple script isn't excatily what you need but its a start. I'm not sure how to fully request root access to an application from inside the application its self, But for testing, you can always just run your application as root and continue your debugging

    Please let me know if this helped you in any way or not

提交回复
热议问题