I am trying to define a keyboard shortcut in BTT for the Preview app that maps CMDS to
- export to PDF if the open file is a PDF file or
- perform regular save if it isn't.
The AppleScript I have developed for the shortcut looks like this:
tell application "Preview" to set filePath to path of front document
if filePath contains ".pdf" then
tell application "System Events"
keystroke "e" using {shift down, command down}
delay 0.5
keystroke "g" using {shift down, command down}
delay 0.1
key code 51
keystroke filePath
key code 76
delay 0.5
key code 76
delay 1.0
key code 48
delay 1.0
key code 49
end tell
else
tell application "System Events"
keystroke "s" using {command down}
end tell
end if
I like the CMDS shortcut triggered in the else
statement to be directly sent to Preview instead of being captured by BTT.
Can I achieve this either by
- modifying my AppleScript or
- moving the conditional statement to BTT to only run the script if the file type is PDF?