Skip to main content
added 16 characters in body
Source Link
user3439894
  • 59.8k
  • 10
  • 112
  • 135

If you just want to open the most recentrecently closed document in Preview, then the following example AppleScript code used in a Run AppleScript action in an Automator Service/Quick Action can beand assigned a keyboard shortcut in: System Preferences > Keyboard > Shortcuts > Services can do it.

If you want to choose forfrom the Open Recent menu in Preview, then the following example AppleScript code used in a Run AppleScript action in an Automator Service/Quick Action workflow can beand assigned a keyboard shortcut in: System Preferences > Keyboard > Shortcuts > Services can do it.

If you just want to open the most recent closed document in Preview, then the following example AppleScript code used in a Run AppleScript action in an Automator Service/Quick Action can be assigned a keyboard shortcut in: System Preferences > Keyboard > Shortcuts > Services

If you want to choose for the Open Recent menu in Preview, then the following example AppleScript code used in a Run AppleScript action in an Automator Service/Quick Action workflow can be assigned a keyboard shortcut in: System Preferences > Keyboard > Shortcuts > Services

If you just want to open the most recently closed document in Preview, then the following example AppleScript code used in a Run AppleScript action in an Automator Service/Quick Action and assigned a keyboard shortcut in System Preferences > Keyboard > Shortcuts > Services can do it.

If you want to choose from the Open Recent menu in Preview, then the following example AppleScript code used in a Run AppleScript action in an Automator Service/Quick Action workflow and assigned a keyboard shortcut in System Preferences > Keyboard > Shortcuts > Services can do it.

added 228 characters in body
Source Link
user3439894
  • 59.8k
  • 10
  • 112
  • 135

The example AppleScript code is just that and does not contain any error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted.


The example AppleScript code is just that and does not contain any error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted.

Source Link
user3439894
  • 59.8k
  • 10
  • 112
  • 135

My question is if there is a keyboard shortcut to open a recently closed preview file?

The following was tested in macOS Catalina 10.15.6 and worked for me while Preview has focus. (No third-party applications needed.)

If you just want to open the most recent closed document in Preview, then the following example AppleScript code used in a Run AppleScript action in an Automator Service/Quick Action can be assigned a keyboard shortcut in: System Preferences > Keyboard > Shortcuts > Services

  • In the Run AppleScript action in the Automator Service/Quick Action, replace the default AppleScript code with the following example AppleScript code:
tell application "System Events" to ¬
    click first menu item of ¬
        menu 1 of menu item "Open Recent" of ¬
        menu 1 of menu bar item "File" of ¬
        menu bar 1 of application process "Preview"

enter image description here


If you want to choose for the Open Recent menu in Preview, then the following example AppleScript code used in a Run AppleScript action in an Automator Service/Quick Action workflow can be assigned a keyboard shortcut in: System Preferences > Keyboard > Shortcuts > Services

  • In the Run AppleScript action in the Automator Service/Quick Action, replace the default AppleScript code with the following example AppleScript code:
tell application "System Events" to ¬
    set OpenRecentMenuList to ¬
        get name of menu items of ¬
            menu 1 of menu item "Open Recent" of ¬
            menu 1 of menu bar item "File" of ¬
            menu bar 1 of application process "Preview"

if the number of items in OpenRecentMenuList is greater than 2 then
    set OpenRecentList to items 1 thru -3 of OpenRecentMenuList
else
    display dialog "The Open Recent menu is empty." buttons {"OK"} default button 1
    return
end if

set menuItem to (choose from list OpenRecentList) as string

if menuItem is "false" then return

tell application "System Events" to ¬
    click menu item menuItem of ¬
        menu 1 of menu item "Open Recent" of ¬
        menu 1 of menu bar item "File" of ¬
        menu bar 1 of application process "Preview"

enter image description here


I assigned the following keyboard shortcut to the Automator Service/Quick Action in: System Preferences > Keyboard > Shortcuts > Services

enter image description here


Note: The usual security caveats apply. Permissions will need to be granted as prompted and or required in: System Preferences > Security & Privacy > Privacy >