Why am I unable to see any available accessibility actions on a AXUIElement in macOS?

78 views Asked by At

I'm working on project that uses macOS accessibility APIs, but I can't seem to get even a simple example to work. I'm new to Swift and the macOS APIs and I'm struggling to see what I'm doing wrong.

I wrote the following script as a minimal example of the problem I'm having:

import AppKit

// Get the system-wide accessibility object
let systemWideElement = AXUIElementCreateSystemWide()

var elementActions: CFArray?
let err = AXUIElementCopyActionNames(systemWideElement, &elementActions);

print("trusted: \(AXIsProcessTrusted())")
print("available actions: \( elementActions! as [AnyObject] as! [String])")
print("got an error: \(err != .success)")

I get the following result:

trusted: true
available actions: []
got an error: false

trusted: true validates (I think) that I granted the application access to Accessibility info (in Settings > Privacy and Security > Accessibility).

Where I'm getting stuck is that my available actions list is coming up empty. I expect to see something here.

If it's helpful .entitlements doesn't specify any specific entitlements - I've tried some things here but haven't had any luck.

Thanks for the help!

0

There are 0 answers