Can't use macro to type text in a password field

I’m new to KM but have used Quickeys for years. I made a KM macro to type text that I commonly use as a password when required by the system. This works when simply typing it into a word processing window but when I use it to unlock a system preference the Password dialog just vibrates and rejects the text. Although I can’t see the actual text it looks like it is inserting the correct number of characters. What’s wrong. Does KM not allow password macros?

Hey @toshy,

I just tried this with my system Users & Groups prefs and the Click the lock to make changes dialog.

Insert text by pasting fails, because the password field is a secure-field.

However Insert text by typing works fine.

If this does NOT work for you please specify exactly what preference you’re working with and what version of macOS.

-Chris

Thanks.
I am using the type text macro and the letters (encrypted) do appear in the box but they do not operate the password. If I insert the macro into a normal word document then the letters appear as expected.
System is 10.12.1

I can’t test at the moment, but it would appear that Apple has changed something in favor of more security.

Bump.

-Chris

Thanks again. Still works ok with Quickeys tho.

Oh, really. Then something is afoot as Holmes would say.

Again – please specify exactly what preference you’re working with.

An alternative method of working with it may be possible.

-Chris

Hi Chris

Just in case it was a local problem I’ve installed KM on another machine but have similar failures – it won’t insert into a password field but will insert into a text document

Here is a screenshot of my macro

BUT there is a difference here in that KM is now trying to insert only 7 characters instead of the 8 in the password – see below – although when inserting into text document all 8 characters appear properly.

Toshy

Hey @toshy,

Weird. Try changing your keyboard shortcut to something completely innocuous like F1.

I’ll be back in a few minutes with a script that may help…

-Chris

Hey @toshy,

I haven’t installed Sierra yet, so I won’t guarantee this will work. (It works fine on El Capitan.)

The system password dialog needs to be frontmost when this AppleScript is run from an Execute an AppleScript action (text-script). Try running it in isolation before adding it to any macro sequence.

Set pValue to your actual password. (Be aware – automating entry of your password reduces the security of your system somewhat.)

-Chris

--------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2016/12/18 21:14
# dMod: 2016/12/18 21:23
# Appl: System Events & SecurityAgent
# Task: Set the value of the system password dialog's password field
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @System_Events, @SecurityAgent, @Set, @System, @Password
# Test: Works on El Capitan 10.11.6
--------------------------------------------------------------------------------

set pValue to "IamNuts!"

tell application "System Events"
   set securityAgentProcess to processes whose name is "SecurityAgent"
   if length of securityAgentProcess = 1 then
      set securityAgentProcess to item 1 of securityAgentProcess
   else
      error "The Security Agent Process is NOT running!"
   end if
   
   tell application process "SecurityAgent"
      tell (first window whose subrole is "AXStandardWindow")
         
         tell (first text field whose name is "Password:")
            set value to pValue
         end tell
         
         # Uncomment to let the script press the [Unlock] button for you.
         # tell button "Unlock"
         # 	perform action "AXPress"
         # end tell
         
      end tell
   end tell
end tell

--------------------------------------------------------------------------------

Well, changing the password macro to f6 made it work. Did you try a macro triggered by Control p in a password dialog box?

Thanks for all your help

Toshy

Hey @toshy,

Good deal.

Yes – but it works fine for me on macOS 10.11.6.

You may have something else on your system that uses Ctrl-P and is colliding with the Keyboard Maestro macro.

The fact that QuicKeys work and Keyboard Maestro didn’t made me suspect the trigger.

-Chris

Sounds like:

Troubleshooting - Sometimes Typing in Password Fields Drops Characters