JPEGmini Pro seems to be a poorly implemented cross-platform app, so some things aren’t working as they would with “real” apps. Namely, the usual Open With action or a shell script with open doesn’t seem to work, it just returns this:
So, we have to do something very clumsy and use the Open menu item in the app’s File menu:
Make sure the macro is in a macro group only active when Finder is frontmost.
Make sure the macro group and the macro itself are enabled.
Change the hotkey trigger of the macro to your needs.
In JPEGmini’s preferences set an export folder.
In the Finder, select one or more JPEG images.
Run the macro via hotkey trigger.
Troubleshooting:
If the macro gets stuck somewhere during the Open dialog, try inserting a Pause Until action before the Press Go Button and/or the Press Open Button action. (Similar to the Pause Until Open Enabled action a few lines above.)
Other issues: First quit and relaunch KM Engine (last menu item in KM’s File menu).
How the macro works:
For each Finder-selected file it…
tests if the file extension is jpeg or jpg
makes sure JPEGmini is frontmost
opens the Open menu item of JPEGmini and inserts the file path in the Open dialog, pressing the necessary buttons to advance and finish the dialog
If one of the selected images is not a JPEG, is throws a notification and continues with the next one in the selection.
Tested with Keyboard Maestro 9.0.5 on macOS 10.15.3.
The macro still might need some fine tuning on your setup.