Pressing the "Always Allow" button on Keychain permission dialogs

Hi everyone!

Is there a way to interact with system alert dialogs (like the dialog that comes up when some app wants to access something from your keychain) without relying on fragile mouse clicks?

In particular, I want to make a macro that will press the "Always Allow", but KM can't find the button, I expect because it's looking at the front application window and not that system alert.

Thanks,
Scott

This sounds dangerous, but that's your call. What if the alert was "A remote user wants to take control of your computer - Always Allow?"

AppleScript is always the right way to solve this, but you said KM can't find the button, which seems to imply AppleScript wouldn't work either. Therefore I see two solutions. Either way, you need to answer how quickly do you need these buttons detected and pressed? Do you need it roughly once per second or will once per minute suffice?

  1. Create a loop using Find Image. I can't guarantee there won't be false positives.
  2. Create a loop that calls a macOS shortcut that performs OCR on a certain part of the screen (where the error message may occur). This OCR is extremely fast and accurate. I feel that it works better on M1 Macs. When the error message appears, use the KM mouse action to click the mouse. This method will probably never have a false positive.

I could probably write the macro for you, but I haven't done my morning errands yet.

Thanks. To be clear, I'd be triggering this menu through the KB menubar item. So I'm not really worried about cases where I definitely should not be pressing the button. My main peeve is that no only do I end up having to type the password frequently, but I have to move the mouse to hit the Always Allow button. The keychain item of concern is changed every day, which seems to reset app permissions, and even though that keychain item is marked as unrestricted, the system insists on asking me to approve access.

For now, I just put in mouse coordinates from the main screen. That should work as long as I never move that dialog box.

Oh, I thought you wanted the system to detect the condition. Just use a single Mouse Click action which uses "Find Image" to find the OK button. It sounds like you are hardcoding coordinates instead of using Find Image. I guess that should work, but only if the dialog box doesn't change size/position. I'd feel safer using Find Image.

Hi Scott - welcome to the forum.

It would not surprise me to learn that macOS/Apple is not exposing that button to anything because they do not want to allow for it to be automatically clicked.

If it’s being automatically clicked each time i can’t imagine why you would end up moving it.

It could be moved by things like rotating a monitor, changing resolution, and other things. This is why I recommend Find Image.

You're totally right Sleepy. No idea why that didn't occur to me! Thanks for gently correcting me :slight_smile: