I’m automating downloading invoices from a website (Obsidian) using Keyboard Maestro. The current sequence of actions is:
Summary of Keyboard Maestro Actions
- Open a specific URL (Obsidian Billing page) in Safari.
- Wait for Safari to load (3 sec).
- Execute JavaScript in Safari to click the button on view the invoice list.
- Wait again for the next page to load fully (3 sec).
- Execute JavaScript in Safari to click a button to select the latest invoice
- Wait once more (3 sec).
- Execute JavaScript to click “Print invoice,” opening the Safari Print Dialog. (There is no option to download the invoice)
- Pause for 2 seconds to ensure the Print Dialog is fully visible.
My issue
- After the Safari Print Dialog appears, I want Keyboard Maestro to select “Save as PDF” automatically.
- However, no Keyboard Maestro action (Keystroke action, AppleScript keystrokes, or Click at Found Image) has worked reliably to trigger “Save as PDF”. I have created a Keyboard shortcut in the system settings for calling Save as PDF. When a keystroke action calls this shortcut nothing happens.
- It seems the Safari Print Dialog prevents Keyboard Maestro’s input from being processed until the dialog is manually dismissed. After dismissal, the queued input occurs too late. I created a test macro triggered by a keyboard shortcut calling a keystroke action with the Save as PDF shortcut. That works when I trigger it via its shortcut in the dialog.
I’m looking for a robust and reliable method to have Keyboard Maestro automatically select “Save as PDF” from Safari’s print dialog.
Does anyone know why Safari’s print dialog is blocking Keyboard Maestro automation, and how I can reliably automate selecting “Save as PDF”?