Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Focus required for interactions #37

Open
nameghino opened this issue Dec 19, 2022 · 4 comments
Open

Focus required for interactions #37

nameghino opened this issue Dec 19, 2022 · 4 comments

Comments

@nameghino
Copy link

I'm trying to build a sort of POC for a software remote controller to Keynote to pass slides and I found that whenever I click on my application's UI to trigger a Keynote change, nothing happens unless Keynote is in foreground, so I have to resort to cmd+clicking on my app so that Keynote remains foreground and then the AXPress event is sent and received by Keynote

I've tried using AXRaise to bring Keynote to front before sending the AXPress event but I find that it's still not received.

Is there something I'm doing wrong? How can I use AXSwift to bring Keynote to front so that my events are delivered?

Thanks!

@soundflix
Copy link

soundflix commented Dec 19, 2022

Try to AXRaise the parent window of the element that you want to perform an action on.

@nameghino
Copy link
Author

I tried sending AXRaise to both the Application object and to all its top level windows, still doesn't work.
However, I got it to work by using the NSWorkspace APIs and then calling activate(withOptions:) on the target app.

@soundflix
Copy link

soundflix commented Dec 20, 2022

What do you mean with "top-level windows"? A window is always first level above Application. And you have to raise the window that contains your target element, not all.
But some apps just don't behave so well with Accessibility.

@DavidMolnar-RS
Copy link

DavidMolnar-RS commented Jan 11, 2023

Some (not all) AX Objects for buttons and the like will have an attribute ".focused". Check if the ".focused" attribute is there and then set it to "true". Once you set this, then try your .performAction(.press). I found this was a requirement from Big Sur and later for some AX Objects. Use the Accessibility Inspector and see if an attribute "Keyboard Focused" is there and if it is set-able.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants