Script works via Script Folder but not Smart Rule

I wanted to use DT to solve a problem of certain apps not printing nicely, such as Bear, Apple Mail and when I want to print selected text.

I wrote a keyboard maestro macro to simply print (⌘P → select print set → print) which I converted to a script as per below

I tested the script in the scripts folder and it works perfectly

I then created a “Print” subgoup in my Inbox and created a smart rule so that anything that is imported into the Print group is automatically printed.

I added the script to the ~/Library/Application Scripts/com.devon-technologies.think3/Smart Rules directory, and created the smart rule below.

On import into the Print group I get the error message below.

thanks in advance for your time and help

tell application "Keyboard Maestro Engine"
	do script "3FB427CA-6C75-40C7-B865-120A0DDD611A"
	-- or: do script "Print Document"
	-- or: do script "3FB427CA-6C75-40C7-B865-120A0DDD611A" with parameter "Whatever"
end tell

The script doesn’t have a performSmartRule function and doesn’t perform any DEVONthink specific commands, actually it just tries to perform a Keyboard Maestro macro and this depends probably on the current state of the user interface, the keyboard focus and the selection. But as smart rules are executed in the background (independent from the user interface and the current selection) and shouldn’t require user input, I actually doubt that this will (reliably) work even after fixing the basic flaws.

Thank you Chrisitian. So There is basically no way to trigger 2 keystrokes in a smart rule ?
1- ⌘P
2- pause
3- Enter

You can trigger keystrokes but it wouldn’t perform the desired actions due to the mentioned reasons.

1 Like

OK. thank you Christian

how I understand. thank you

You can try this…
Print on (1.6 KB)

Unzip the attached smart rule and double-click to install it. You’ll need to set the targeted group and a target for the Move action.

1 Like

A huge help. Thank you very much. Emails don’t print correctly but I am working on a solution - first convert to PDF. thanks VERY much !!

You’re welcome.
Ahh… I see what you mean regarding emails. Thanks for the heads-up.

I am struggling with first convert docs to PDF, then delete non PDF, then print with your excellent script.
I know how to perform all those actions with a smart rule.
My question is how you go about creating a sequence of actions in a smart rule ?
in keyboard maestro one can insert delays, but that does not apply here
thank you