Whenever a new file is put into a folder, open that file in Preview (fullscreen, if possible).
Background: I’ve got a remote control software for my camera, and when I connected it to my mac, and take a new picture, this picture is automatically put in a folder of my choice. Now what I’d like to have is that this new file is automatically opened and displayed in fullscreen, so that I have sort of a “much bigger camera screen”
Here is my attempt:
on adding folder items to this_folder after receiving these_items
tell application "Preview"
activate
open these_items
end tell
end adding folder items to
the script itself seems to work, but for a folder action there are some requirements:
¢ The script must be located in /Library/Scripts/Folder Action Scripts/ or in ~/Library/Scripts/Folder Action Scripts/
¢ Folder actions must be enabled
¢ the script must be attached to the hot folder
That’s right. But there is a way to avoid telling Preview.app something
on adding folder items to this_folder after receiving these_items
tell application "Finder"
open these_items using application file (path to application "Preview")
end tell
end adding folder items to
on adding folder items to this_folder after receiving these_items
-- close preview
tell application "Preview" to quit
-- give it some time
delay 0.5
-- open new in preview
tell application "Finder"
open these_items using application file (path to application "Preview")
end tell
-- now go fullscreen using keyboard shortcut
tell application "System Events"
tell application process "Preview"
keystroke "f" using {command down, shift down}
end tell
end tell
end adding folder items to
The first bit is to get rid of a previously opened instance of Preview… haven’t managed to smoothely exit fullscreen, close the current file, and then open the new. But brutally closing it does the trick