Show pallet with folder contents?

Is there a way to create a pop-up Pallet that shows a contents of a folder with the ability to click on the item to launch/open the item up?

Yep. Checkout the Prompt for File action. After picking the file, use the Open a File action.

But you can't get a palette like the KM Macro Group palettes.

It's not clear what you are expecting. The above shows a popup like the normal File > Open dialog.

If you really want a one-click style palette, then you could design your own using the Custom HTML Prompt action. It uses standard HTML and JavaScript, so you can do pretty much anything you see on the web.


I just want to use KM Macro Group palette (that is linked to another pallet button).

Example: KM palette that shows a folder icon, you select it and a sub palette comes up with contents of files that were placed in a folder through out the day. If clicked, can open that particular file. All through KM palettes.


I'm no palette expert, but AFAIK KM Palette items can only be Macros.

I suspect you will need to use another tool to dynamically display a list if files in a folder to open.

If it were me, I'd use the AppleScript choose file command, which can be given a default folder to show.

choose file

Allows the user to choose a file.

choose file required
with prompt text optional
of type list of text optional
default location alias optional
invisibles boolean optional
multiple selections allowed boolean optional
showing package contents boolean optional

I was surprised this wasn't a feature, or something someone had created, and then surprised that it was fairly quick to implement. Albeit not totally cleanly - the 'hacky' aspect is that it's awkward to create & add macros programmatically, so I manually pre-filled the palette with macros containing a stub function. Macros start out disabled, and then "adding" macros is really just enabling them.

Of course, you need at least as many dummy macros as files you expect in that folder. My use is to create a palette of script files for another app.

-- AppleScript to Fill Palette with my scripts

-- populate a KM palette with the file names of a hardcoded directory

-- lacking an easy way to dynamically add macros, the palette is pre-populated (in KM Editor)
-- with sample macros, which we just need to enable, and set the name to a file.

-- this script is triggered by a KM folder action, which causes it to run &
-- update the palette on any change of folder contents

-- obviously, you need to fill out the palette with enough buttons to cover the number of files in the folder

tell application "Finder"
	-- fill in folder path to list. This is the same one as you'll set a folder action for, which runs this script
	set scriptFiles to files of folder "Macintosh HD:Users:yourname:path:to:scripts" 
end tell

tell application "Keyboard Maestro"
	-- your macro group name here, which you've already created
	set scriptPalette to macro group "scripts" 
	set scriptButtons to macros of scriptPalette
	-- Clear the palette (like sherbet) disable all
	-- (applescript's special and maddening talent - set a property on every item in a list)
	set the enabled of the macros of scriptPalette to false
	-- set the names of macro buttons to names of files
	repeat with j from 1 to count of scriptFiles
		set thisButton to item j of scriptButtons
		set name of thisButton to name of (item j of scriptFiles)
		set enabled of thisButton to true
	end repeat
end tell

As far as the action when the file name is clicked - ie the contents of the macro in the palette, that's up to you. You'll probably want to make use of the variable, %ExecutingMacro%, which will contain the filename that was just clicked

The full workflow:

  1. make a macro group with palette in KM, with a bunch of duplicate macros containing the action to perform when a file is clicked.

  2. Set a folder action macro to run the script above. Fill in the path to the folder to list, and the name of your macro group. this keeps the palette updated whenever files are added or removed.

  3. Extra bonus feature - I made command-click in the palette run an alternate function. in my case, it edits my script file, by opening it with the default app. KM macro snippet attached

edit script on cmd click.kmmacros (3.0 KB)