MACRO: Generate Password, v2.2


Macro Authors: Over the last several months I've created many macros like this with dialogs rendered using the Prompt For User Input action. It’s an amazingly versatile action.

Prior to this macro I've used a global variable to save each of the relevant dialog settings. This approach has worked quite nicely, but the downside has been that the global variable list (seen using the KM Preferences) gets cluttered with these relatively trivial variables.

With this macro I’ve taken a different approach: save all macro dialog settings to a single KM dictionary. See the IMPLEMENTATION NOTE below for more information.

If you are interested in this approach and/or some other dialog box tips, please join this thread: Dialog with Dynamic Popup List

PURPOSE

The purpose of this macro is to generate a complex password. The text value is written to the System Clipboard. The length and components of the password are specified via a single dialog box.

Note: I know there are many ways to generate passwords (including using several other macros within the Keyboard Maestro forum). I’m adding this to the mix. It allows me to very quickly create a long, complex password without leaving the keyboard.

IMPLEMENTATION NOTE

All Generate Password dialog box settings are saved to a single KM Dictionary named jsGP2_dict, where js are my initials and GP2 refers to the name of this macro, version 2. For more information about this dialog box approach, refer to Dialog with Dynamic Popup List.

ACKNOWLEDGEMENTS

The components of the password are randomly scrambled using a Bash shell script obtained here: Bash- scramble characters contained in a string - Stack Overflow

TESTED WITH

  • Keyboard Maestro, v10.0.2
  • Monterey, v12.2/MacBookPro16,1
  • Mojave 10.14.16/Macmini6,2
  • High Sierra 10.13.6/iMac11,1445

VERSION HISTORY

1.0 initial version
2.0 Simplified the dialog and changed the underlying logic to match.
2.1 No change to macro functionality. Corrected the macro name in the IMPLEMENTATION NOTE section of this comment.
2.2 No change to macro functionality. Defined local_DICT and used it rather than hard-codng dictionary name throughout.


DOWNLOAD Macro File:
Generate Password.kmmacros (77 KB)
Note: This macro was uploaded in a DISABLED state. It must be ENABLED before it can be run. If it does not trigger, the macro group might also need to be ENABLED.

Macro-image

5 Likes

Hi @_jims

I really like this Dictionary use for Default Selections. Just one thought on your Macro - at the moment the User is allowed to select multiple lengths which I don't think should be allowed? This is because you are using radio buttons to make the selection. I think it might be better to do something like this:

EXAMPLE - choose length.kmmacros (6.9 KB)

Click to Show Image of Macro

EXAMPLE  - choose length

1 Like

I was wondering the same thing but was curious about using a slider for the password length:

01)Scratchpad.kmmacros (2.5 KB)

2 Likes

I've been trying to find a use for the slider. I think the problem with the slider in its current form is it gives no live indication of what number you are selecting apart from just how far along the line the slider is.

2 Likes

I agree! I wonder how hard that would be to do and if it's something Peter could implement in a future release.

1 Like

Hi @Zabobon and @cdthomer. Thanks for your comments and suggestions. I suspected this butt-ugly dialog might generate feedback. Originally I thought that I'd better try to justify it, but then I decided to throw it out there and let the comments come in. Thanks for playing along. :grinning:

I've had issues with repetitive stress injury from mouse overuse; thus Keyboard Maestro, in general, has been a godsend. Although dialog boxes are great in many ways, they are often not optimized to minimize mouse use.

This might be one place where aesthetics (and mobile) have worked against keyboard-only control of dialog boxes.

Remember radio button controls? More on Windows that macOS, there were radio button controls where the selection (i.e., a mutually exclusive choice) could be made with the keyboard by pressing the character indicated within a buttons label. They weren't pretty, but they were efficient.

CleanShot 2022-02-03 at 07.40.56

In general, radio buttons have gone as the dodo bird and been replaced with popup menus. I suspect that it's because radio buttons are less space-efficient.

Some mac programs have dialog controls that can be operated with the keyboard, however they are rarely indicated with something as obvious as the labels with an underscored character.

So back to my ugly dialog and your suggestions. In light of the Prompt For User Input constraints and my design goal to minimize mouse dependency:

  • @Zabobon's suggested approach is normally what I do, for example in Log It. Popup menus provide a mutually exclusive choice, but they still require more mouse control than I'd like: 1) move the mouse to the popup menu, 2) click the popup menu, 3) move the mouse to the menu item of choice, and 4) click the choice.

  • @cdthomer, if sliders included a numerical indication then they could work (because increments can be clicked; sliding is painful), but as they are designed, IMO they just don't work well for this situation.

Considering my design goals, maybe it would be better to exclude the checkboxes altogether and save the number entered in the Custom Length.

Now imagine the feedback if I had used 1 or 0 values instead of checkboxes for Lowercase Letters, Uppercase Letters, Integers and Symbols. That would have taken this dialog to another level of ugliness, but it would be easier to control without the mouse. :thinking:

BTW, note that there is a similar issue with the symbols: Custom Symbols override Symbols (the full set). I added the Custom Symbols option because some sights restrict the symbols that can be used.


Hum, maybe a Custom HTML Prompt is the way to go.

1 Like

That all makes sense - and I did try to resist jumping in as it's your Macro! :joy:

One further suggestion -

If you don't have all the User Options in the first Prompt, you can do everything with keyboard. You can invoke a dropdown list item with its first letter (like you were saying with the Windows radio buttons) but only if:

  1. You have Mac OS System Preferences set to:
    System Preferences>Keyboard>Shortcuts>Use keyboard navigation to move focus between controls
  2. It is the highlighted field (i.e. blue glow around it) in the Prompt.

(I only know this because there was a recent discussion on the Forum).

EXAMPLE - choose length #2.kmmacros (5.5 KB)

Click to Show Image of Macro

EXAMPLE  - choose length #2

Screen Recording 2022-02-03 at 14.49.18-Animated GIFF 640 12fps

EDIT: In addition to all that, pressing the down arrow key will expand the whole dropdown list and you can then choose either with first letter or down/up arrow keys. And the ⇥ key moves the blue glow to the next item in the Prompt. ⇧⇥ moves it to the previous item. Pressing Spacebar will select the blue glow item - it it's a button, the spacebar will push the button with the blue glow around it.

3 Likes

No, no, no—I appreciate the feedback. If often leads to a better way!

I had forgotten about this. And it seems better than when I tried it many years ago. My memory might be foggy. Until recently, 99% of my computer time was on Windows (at a F100 company). Now that I'm spending much more time on macOS, I need to invest more time learning (or relearning) things like this. Thanks!

Actually with my testing (just now), it appears to work quite nicely with multiple controls:

  • tab to advance from field to field; shift-tab to retreat
  • spacebar to select/deselect a checkbox
  • arrow keys to move between pop-up items; spacebar to select an item
2 Likes

After receiving feedback from @Zabobon and @cdthomer, I revisited my original design goals. This led to a streamlined dialog box which in turn simplified the underlying logic. I've updated the first post in the thread with Generate Password v2.0.

1 Like