I've been having this issue for a while and I have tried many different solutions.
I have a macro that opens a Screen Sharing session using the 'open vnc://...' shortcut. When the session comes up and I see the Login Screen for the connected Mac and the correct user is selected, the macro inserts the user password by typing and then the Return keystroke.
Sometimes this works just fine, and other times the password prompt blinks as though the wrong password was typed.
I have tried:
Extra pauses before and after the text insertion
Changing the action delay for the typing
The Insert Text action inserts the password via a PW variable - I also tried 'Inserting by typing' using the actual password instead of the variable
It's just not consistent.
It always works if I run the macro and then manually type in my password each time - so there's no good reason why KM shouldn't work the same.
Sending keystrokes to a remote session can be problematic when modifier keys are involved -- including Shift. Does the password have uppercase letters or special Shift-ed characters in it?
Interesting that it works for you -- it never has for me. AaBbCcDd is always typed out on the remote machine as aabbccdd (Sequoia on all devices, macOS built-in VNC, the mix of Intel/Apple silicon makes no difference). It works fine typing locally.
But I'm quite expecting that this is a "me" problem!
Hi, @csmu (and others reading this post), I'd recommend downloading and installing the latest version (currently Version 5.0): Insert Text Into Restricted Field
Hi, @Airy. I've not observed processor dependency.
But @Nige_S, you are a special muppet, so special that you helped me work through an issue I had with that macro. (I know that doesn't make me unique; you have helped so many on this forum.)
@csmu@_jims Unfortunately the "Insert Text Into Restricted Field" is also not working for me (I have tried many different 'delay' values as well). It seems to have the same success / fail rate as a manual "Insert Text by Typing" action which is preceded by a "Set Action Delay" action.
@Nige_S your solution is working 100% of the time at the moment (also limited testing). I actually had a nearly identical AppleScript action in my macro already but I had disabled it at some point. I'm wondering if I came across another of your posts with something similar when I was first creating this macro.
The only downside here is that I can't use a PW variable as I need to pass the password to AppleScript, but at least a Local variable is better than nothing.
Are you typing that password into a KM prompt? You could gather it in the AppleScript itself, if you're worried:
set myPass to text returned of (display dialog "Enter your password:" default answer "" with hidden answer)
Downside compared to gathering it in KM is that you can't ask multiple questions in a single dialog, so you can't eg select a target machine and provide a password in one go.
You can limit the "exposure" of the local variable by clearing it as soon as you've got it into your AppleScript:
Even with other actions in-between gather and use, if someone manages to exfil Local_myPass in the second or less it exists -- you've probably got more serious issues to worry about!
For multiple use -- eg unlocking the remote machine then later in the macro do something else that needs authentication, look at pulling the password from Keychain or your password manager every time you need it -- there are certainly examples for the "Set Variable to Keychain Password" action and the 1Password password manager on this Forum, and maybe others.
Yes, I’m pulling the password from the Keychain with the set variable to keychain password action. I’ve been adding a “PW” to the end of the variable name for security until now.
Right, the fact that I’m using the keychain and it’s a local variable is really fine. I’m not all that worried.
By the way, the AppleScript method is working 100% of the time
You can go back to using a password variable -- you just need to pass its value to a local immediately before you execute your AppleScript. If you then get it into an AS variable ASAP then nuke the local from inside the AppleScript you've reduced the time your password is stored in a local to 40-60 milliseconds...
Certainly that's more useful when you are asking the user to input a password as part of a KM dialog and using it later:
Right, yes I can still use the PW variable but because I am already using the "Set variable to Keychain Password" action just before the AppleScript, I might as well just set the "set variable" action to the local variable. But good call on resetting the Local inside the AppleScript, I added that.
For my purposes I'm just running a macro that opens a connection to a specified local Mac, deals with any prompts or connection errors and then waits for the login screen, enters the password and hits return.