Finder Quick Actions Keyboard Shortcut

Is there any way to create a keyboard shortcut for Finder Quick Actions like 'Create PDF'?

As of now - I click multiple PDF's in the Finder - then right/click on them > Quick Actions > Create PDF.

Thanks!

You can work with the Contextual Menu and the Finder-selection using a found image.

See this by way of example:

Drag Finder selection to "Found Image" in Chrome Browser window - #11 by ccstone

From there you can right-click with Keyboard Maestro and drive the Contextual-Menu with one or more Insert Text by Typing actions.

I'm still using Mojave, so I can't check this – on Mojave there is no Finder toolbar button for Quick-Actions.

Is this still the case?

If there IS a dedicated button – you could drive that instead.

I can confirm there seems to be no dedicated button, unfortunately.

OS: macOS Ventura.

1 Like

This macro attempts to execute "Create PDF" quick action opening the contextual menu (using System Events). You can try it:

Quick Action — Create PDF (GUI Automation).kmmacros (2.2 KB)

Source code (Applescript):

tell application "System Events"
   tell application process "Finder"
      set selectedFile to value of attribute "AXFocusedUIElement"
      tell selectedFile to perform action "AXShowMenu"
      delay 0.5
      tell window 1
         tell splitter group 1
            tell splitter group 1
               tell scroll area 1
                  tell outline 1
                     tell menu 1
                        tell menu item "Quick Actions"
                           perform action "AXPress" of it
                           delay 1
                           tell menu 1
                              tell menu item "Create PDF"
                                 perform action "AXPress" of it
                              end tell
                           end tell
                        end tell
                     end tell
                  end tell
               end tell
            end tell
         end tell
      end tell
   end tell
end tell

That's nice.

Although it takes a ridiculous amount of time to run on my old 2012 i7 MacBook Air running Mojave.

More than 4 seconds...

How long does it take on your system and hardware, and what are they?

Thanks for appreciating it.

In my system takes 1,947 seconds.

System:

macOS Ventura
MacBook Air M1 16 GB RAM

I set delays too long. This version uses shorter delays and runs in roughly 1 second.

Download Macro(s): Quick Action — Create PDF (GUI Automation).kmmacros (2.2 KB)

Macro-Image

Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System Information
  • macOS 13.1
  • Keyboard Maestro v10.2

That's embarrassing. I completely missed the delays in the code... :man_facepalming:

I recommend against using fixed delays whenever possible – try watching for the existence of appropriate elements instead:

tell application "System Events"
   tell application process "Finder"
      set selectedFile to value of attribute "AXFocusedUIElement"
      tell selectedFile to perform action "AXShowMenu"
      tell window 1
         tell splitter group 1
            tell splitter group 1
               tell scroll area 1
                  tell outline 1
                     tell menu 1
                        tell menu item "Quick Actions"
                           repeat until exists of it --<< TAKE NOTE
                              delay 0.25
                           end repeat
                           perform action "AXPress" of it
                        end tell
                     end tell
                  end tell
               end tell
            end tell
         end tell
      end tell
   end tell
end tell

Unfortunately this is still horribly slow on my old system – over 4 seconds. One second I could live with but not 4+.

Anyone with older hardware like me will want to go the Found-Image route:


Download: Quick Action ⇢ Finder ⇢ Create PDF v1.00.kmmacros (20 KB)

Macro-Image

Keyboard Maestro Export

Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.

System Information
  • macOS 10.14.6
  • Keyboard Maestro v10.2

Getting the image of your selection color in the Finder with the right borders is a bit fiddly, but you can do it easily enough by zooming way up with the Preview app or your favorite image editor.

Make sure to take the screenshot using:

  • F4
    • Select.
    • Click.
    • Edit as appropriate in Preview.

If you don't use the Option key macOS may add a drop shadow, and that is problematic for the Found-Image action.

It's easy to miss a line in such a big nested block :slight_smile:

I am surprised that takes so long to run in your machine.

Another alternative would be creating an automator workflow, and using the native KM action to run it.

(Not sure whether it returns exactly the same output as the Quick Action, but worth a try)

Download Macro(s): Create PDF using Automator.kmmacros (1.2 KB)

Macro-Image

Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System Information
  • macOS 13.1
  • Keyboard Maestro v10.2

Automator workflow:

Create PDF (Workflow).zip (111.1 KB)

1 Like

Wondering if it's possible to have access to all the Quick Actions I have and choose one. I need to select some folders (or items) in Finder and call for all Quick Actions available, pick one and go, all with the keyboard only.
Is this possible?

Thanks in advance

Haven't tested, but perhaps you could use an approach to obtain all your Quick Actions for the selected items using GUI scripting.

You could:

  • open the contextual menu using GUI scripting,
  • open a KM palette, and
  • use a shortcut to pick from that list and again use GUI scripting to actually click on the item.