Would It Be Possible to Build a Macro for Ordinal Passwords? (Eg, Enter 2nd, 4th and 5th Digit From a 6-Digit Pass)

I have a few number of internet accounts that, in addition to a normal password, ask for a sub-set of items from a numerical pass. E.g., my pass might be: 578314. On logging in I'm asked for the 2nd, 4th and 5th digits—7, 3, 1. The ordinals picked should change on each log in. I use 1Password but it doesn't seem to help on these kinds of passes.

I think that it would be possible to have a Keyboard Maestro macro help. It would need a 'Prompt for user input' action (e.g., 2nd, 4th and 5th; probably with Checkboxes) and end with 'Type a keystroke'. It's the steps in-between that are puzzling me.

I'm nothing close to a coder but I've found the JavaScript function 'slice'.

let array = [5, 7, 8, 3, 1, 4]
array.slice(0, 1)   // returns [5]

So, presumably I could have this run in Keyboard Maestro for each of the ordinals that are checked then typed in. Is this the best way to proceed? It seems a clunky way to do it and being a KM noob, I can well imagine that there are better ways.

BTW, I'm not too worried about potential security problems here because the macros wouldn't be kept with any other log-in information.


Hi Jasper,
I've come up with an approach you should be able to use.

The macro first "gets" the password - for my tests I just set a variable Local__PW to your example of 5,7,8,3,1,4 (Note - no spaces) This is treated as an array in KM. You need to replace this red-coloured action by whatever actions you need to get the actual password.

It then prompts the user to type in a string representing the characters required ordinally from the password. In your example, the typed-in string would be 245 I originally tried using a prompt with checkboxes, but it is much quicker to just type the string and it also allows for passwords of any length up to 9 characters and you can specify any order like, for example, 425. In the macro this string is stored in the variable Local__Mask

Anyway, the macro continues by converting this mask to a list (using the Search and Replace action) and then steps through the list one line at a time; at each step the corresponding character from the password is obtained (using simple array indexing).

At this stage my macro outputs debugging information (in the yellow group). In your use case you should disable this yellow group and enable the following green action which simply types the password character. You may need to perform some other actions to ensure the typed characters get into the correct fields.

This example I'm providing is not a fully polished macro, but simply a good place for you to start. I hope it is helpful.

Test Ordinal PW.kmmacros (5.0 KB)

KM 0 2021-11-13_13-49-34


I am sure @tiffle's approach will lead to what you want but I just wanted to mention that 1Password does have a way to help with these kind of password fields. By right-clicking on the password 1Password gives you and option to "Show in Large Type". This produces a window that floats above all others and numbers the position of each password digit. This makes filling in these kind of password fields a lot easier.





Well - I never knew that! Thanks @Zabobon


Oh thank you tiffle!

I'm a noob just expecting/hopping for some KM sage to say either nah-impossible or try looking at... I wasn't expecting you to build it :blush:

I did as you'd said and enabled/disabled the last and penultimate steps. It then worked in text documents. √

I next tried it in a real account log-in. It stalled on the first of the three fields. I just needed to finish-off with "type the ⌘ Tab keystroke". It then pasted each of the three sampled ordinals from the pass into their correct fields and I was in!

Here is a version of the macro, should anyone else need it.
Ordinal PW paster [123456].kmmacros (7.8 KB)

Thank you also Zabobon,

I discovered this in-between my post and your response. It's nice to have a couple of options now!

Well, I already had a macro that did something similar so it wasn’t much work to modify it. The hard bit was writing the description. I was thinking you might have to put in extra keystrokes but I left that to you. So good news - it works for you and now you’ve shared it! :clap: KM is amazing…

1 Like