Select Item in Drop Down Menu in Print Dialog Box

How do I select an item from this drop down menu in the print dialog box?

I am able to achieve this with keyboard shortcuts in macOS (see below); however, I would like to do this in KM so these macros will sync between my macs.

I've been able to replicate most keyboard shortcuts in macOS to KM with the "Select or Show a Menu Item" command, but I am not seeing the print dialog box drop down menu items from this KM command. Am I, perhaps, missing something? Again, I would appreciate your help.

No, you’re not missing anything. However, if it has a keyboard shortcut, you can always use the “Type a Keystroke” action to trigger the shortcut.

Or you could use some “Type a Keystroke” actions to do down-arrows, and enter.

Or you could use “Click at found image”, and screen-grab the part of the menu with the item to click on. Be careful with this method, however, if you have “Transparency” enabled, because it most likely won’t work all the time.

Most often, the menu items in a dynamic, drop-down menu button, like "PDF", are NOT available to KM because they are dynamically generated.

However, AppleScript can cause the menu to be shown, and then has access to these menu items.

Please checkout this macro, and let me know if it works for you:

You’ve set some shortcuts using macOS. Everything should work if KM simulates those keystrokes.

For example, you have Command-P for Save As PDF, set using the OS. I have that as well. I then have a KM macro that gets me there by simulating Command-P once to invoke the Print dialog, pauses, then simulates Command-P again to invoke Save As PDF. Something similar should work for the situation you describe with any of the drop-down menu commands you’ve created.

If pressing the menu shortcuts works, then simulating the keystroke with Keyboard Maestro should work, but because the latter part of the menu is dynamic, it may not be generated until you click on it in which case typing the shortcut will not work, either manually or using the Type a Keystroke action.

You can display the menu using the Press a Button "PDF" action, eg:

3 Likes

Great idea, Peter.

I just learned something very interesting.

When testing selection of a drop-down menu (like the PDF button menu), you have to manually type enough of the menu item to be unique. The selection is NOT necessarily made in order of the items shown.

So, when I type "Save as", here is what I see:

But if I keep typing so that I have typed "Save as PDF", then the proper item is selected.

Before I wrote my macro, I had tested using your approach, but I didn't type enough of the menu item name in my manual test.

@millerstevew et al:

Thanks to Peter's suggestion, I have been able to greatly simplify, and extend, my macro.
Please see Ver 2.0:
MACRO: @PDF Choose PDF Menu Item in Print Dialog (All Browsers) [Example]

If you type “Save as” the system will select the alphabetically first menu that starts with “Save as” which in this case is “Save as Adobe PDF”. If you type “Save as PDF” it will select the correct one.

Curious point about the UI.
IMO, this is not intuitive. I would expect the first item on the menu list that matches the text to be selected -- not an alphabetical sort.

Still, my point is, to be sure of a selection, type enough text to be unique.

It follows from other type-select places where the ordering may change. For example, you can use type select in the Finder in a Finder window, and it selects the same file regardless of the sort order of the listing.

Definitely. Probably the entire name ideally, even the ellipses if possible (and if it works).

1 Like

Noted, and added to my knowledge base.

Thanks for the help everyone (and sorry for my slow delay). I’m new to KM, and this is super helpful!

@millerstevew,

If any of the above posts solved your problem/question, please check the “Solved” checkbox at the bottom of that post. You can find my post here.

Otherwise, please post your remaining questions/issues about this problem.
If you have other questions, please start a new topic.

A post was merged into an existing topic: @PDF Choose PDF Menu Item in Print Dialog (All Browsers)