MacOS – how to assign keyboard shortcut to buried command

google-chromekeyboardmacospdfprinting

In Chrome, if I do cmd+P to print, and click Print Using System Dialog, then click on the PDF dropdown button, I get a command called Save PDF to DEVONthink Pro.

In System Preferences > Keyboard > App Shortcuts, I created a shortcut named Save PDF to DEVONthink Pro. But pressing that keystroke has no effect.

How do can I call this command using a single keystroke?

Best Answer

Here is the code :

tell application "Google Chrome"
    activate

    tell window 1 to tell active tab to print
    tell application "System Events" to tell process "Google Chrome"
        delay 1
        tell window "Print"
            click menu button "PDF"
            delay 1
            try
                click menu item # of menu of menu button "PDF"
            end try
        end tell
    end tell
end tell

Just replace the #with the index of your script in the menu. (FYI : 1 is Open PDF in Preview, 8 is Save PDF via Messages