Unable to run macro to open USB device, insert password and open


I have a password encrypted USB stick that I am constantly using between two systems so I would like to speed up this little action.
It seems this should be fairly easy...

  1. Trigger by : This USB Device "xxxx" is attached
  2. Pause for 3 sec - trying to debug to see whether action Insert text was running before password window popped up
  3. Insert text "mypassword" by Pasting
  4. Type enter keystroke to enter
  5. Open Volumes/xxxx with Finder

I insert the USB stick, the popup window comes up and nothing further.
When I try to test it in the edit window whatever is highlighted then gets the password edited in - the name of the macro, the pause field even.
I've tested it with Any USB device - it works up to trying to open the Finder window. If I run Try (once it is open), it will then open the Finder window. But not when I insert my USB device. I'm wondering if it does not like the naming of the Volume even though I navigated to it when I set up the action.

I guess I could just record the keystroke actions but it would be a pity not to use the actual actions that KM has for all these actions.

Thanks for any advice.

Have you tried manually pasting something into the field with Cmd+V? Some password fields won’t accept pasted text. In which case, try changing to “Insert by Typing”. Hope it’s that simple :grinning:

Yes, manually inserting pasting text works. But also when I made it so that any USB device that is mounted not just that specific one, it worked up to opening a Finder window.

That is because the Macro is still waiting for something before moving on to the paste Action. It looks like what it is waiting for, is to be in a text field (that's why it pastes into whatever Action you happen to edit in your Macro next).

I would take a step back and try this:
Go through the exact steps you take to do this without Keyboard Maestro.
You plug in your USB drive.
Does the password field just pop up?
Or do you have to try and open the USB drive for the password field to pop up? (I would guess that this is more likely)
When the password field pops up is it ready for text or do you have to click in it?
Do you then have to hit the Enter Key?
And then does the drive open up in a Window in Finder?

It's not so much recording the keystrokes but (at least at first) seeing if you can replicate what you are doing manually using a series of Keyboard Maestro Actions. And a good tip is to add timed Pause Actions between each of the steps (and I see you are doing that). Once everything is working you can see if it works without the pauses.

Once you have something that basically works then you can see if you can refine it.

I will try the keystroke recording option as well and see what it records.

Sounds like you are doing all the right things.

One more thing to try. Make a one Action Macro that does nothing but types the password. Give this a hot key and see if it works to put the password into the field when it is open.

And… once you have manually done all the first steps, does a Macro that just does this one opening Action work?

(One way to make sure you have the path correct is to actually drag the icon of the drive into the path field of the Open with Finder Action when you are editing the Action).

Oh, and I should have said this right away. Could you upload a screenshot of your actual Macro? Much quicker to tell if there is an obvious mistake than a typed out list. It would be good to upload the Macro file too.

You can use File>Export to export the Macro. And Edit>Copy as Image to get an image of the Macro. You can then just drag the Macro file and Paste the Image into your post and they will upload.

Is this any old USB stick that you've encrypted yourself with Disk Utilities, or something intrinsic to that stick? It may or may not matter to how the macro behaves, but if it's the former it'll be a lot easier for other to test for themselves without feeding back potentially duff info.

Update: I found a USB stick I could erase to an encrypted volume in DU, so...

It looks like the OS's decryption password dialog box doesn't respond to KM input using "Input text by Pasting" or "Type the Cmd-V Keystroke" actions (tested with a "beep" action at the end of the macro to make sure it actually ran).

But it does work with "Insert text by typing" -- include the Return key in there as well, so the action's field will be in the form mypassword%Return%. I also had to add a delay to get the "Open in Finder" action to work -- how long may depend on various things so I used an "Until named volume is mounted" action as a pause.

Change password, volume name, and shortcut to suit and give it a go:

Encrypted Test.kmmacros (2.5 KB)

1 Like

Aha, I will give that a try. Thanks.

It kinda works - I have a 4 character password and it types in the first 3 digits only. I've tried to do a pause after before the return but it has the same reaction still.

Weirdly enough it might be that the typing is happening too fast and tripping over itself.

You can play with the speed of the Insert Text by Typing Action like this:

1 Like

Thanks, that definitely works.