Is there a keyboard shortcut, or a way to create one, which does the equivalent of clicking the locked lock icon in the bottom left corner of locked System Preferences panes (which brings up the authentication dialogue)?
While there is no explicit keypress that will take you directly to the Lock icon that I know of, you can hit the Tab key repeatedly to select the tabs and checkboxes in a System Preferences window (I tested with the Security & Privacy window) and end up at the Lock icon, which is then selected.
Hit the Space bar, and the lock opens to the credentials login.
You will need to have System Preferences > Keyboard > Shortcuts > Full Keyboard Access > All controls radio button selected:
Thanks, Nimesh, for pointing out this radio button. I had it enabled, but did not realize it.
You could do it using Keyboard Maestro. Sometimes these solutions are a bit janky, but this is simple enough that there shouldn't be issues, like having to add delays and such. Sometimes you have to add delays if you're using it to navigate a GUI and your computer is a bit slow. Like if you are going from one page to another you might have to wait for a bit before clicking, but since the assumption is that you're already looking at the correct window, all you have to do is simulate a click in the right location. A big hurdle with this solution is that if you don't already own it, keyboard maestro is pretty expensive... It has a trial though, so try before you buy.
You could do it with a simple automated mouse click. I made a gif to show that it works.
- If you want to restore the mouse location after the click, you can find
restore mouse locationin the corner menu of the action.
- Make sure the click is
relative to the front window's bottom left corner
- You can use the get button to get the right location. When you click it, you have 5 seconds to activate the target window and hover over the target location.
So as long as the current window has the lock in the same bottom left corner, it'll get clicked.