Screen Sharing Login Screen 'Insert Text By Typing' not always working

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.

Thanks for any ideas!

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?

Ah, yes it has both uppercase and special characters.

I had the same issue. Asked pretty much the same question.
The answer I got was to use Insert Text into Restricted Field.

I have had no hassles with passwords with upper case letters and special characters since using Insert Text into Restricted Field.

Hope that helps
Cheers

Keith

1 Like

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!

It is indeed interesting that it works for me.

Often the same technique of Insert Text into Restricted Field - into a normal text area fails.

Worse case I use Insert Text into Restricted Field as a placeholder to remind me what to type in!

Insert Text into Restricted Field works for me so often I am surprised when it doesn't.

I've use version 3.

Possibly because of your Intel-based CPU?

Hi, @Nige_S. That's interesting. Have you tried adding a delay between characters? If not, I'd start with 5.

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.

1 Like

As I said, I've tried a mix of Intel and Apple Silicon -- in both directions. Nothing works.

0, 5, 10, 100, 500... No difference.

This is going to be me/my setup -- no need to worry yourself about the one muppet who can't get it to work :wink:

1 Like

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.)

image
?

1 Like

I'd note that this:

image

...doesn't work for me either -- a lower-case a is typed.

This, however, seems to work just fine (limited testing):

image

...which may help anyone else who is similarly stuck.

2 Likes

Thank you all for your input.

@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:

image

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! :wink:

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 :metal:

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:

Use then Clear Password Variable.kmmacros (5.4 KB)

Image

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.