AppleScript App to start a Slideshow in Finder

applicationsfinderscriptslideshow

I want to write an AppleScript App that starts a full screen slideshow with all pictures in the currently active folder in Finder (on Big Sur/Apple M1).

Manually, in Finder I would have to open a folder, press command ⌘+ A to select all pictures (or files) inside, then press option ⌥+ spacebar to start the slideshow.

I want to write a Script-App, that does all that for me (and which I then can put in Finder's toolbar). I am a newbie to this all, so please explain it for the dummy I am!

Best Answer

I figured it out and wrote a simple script, that does this: 1) opens the selected folder in Finder 2) selects all files in that folder 3) starts slideshow. Can be saved as an App and then put in the toolbar of Finder. Works on Big Sur/M1, however you have to allow Script Editor and this App 'Accessibility' and 'Automation' in System Preferences/Security&Privacy.

Any improvements are highly welcome! Especially I couldn't figure out how to make the Script close the selected/opened Folder again and go one level up again. Key code for that would be "key code 126 using {command down}" (for COMMAND+ARROW UP); however, don't know how to integrate that into the script so that it actually works.

tell application "Finder"
    activate
    tell application "System Events"
        tell process "Finder"
            key code 31 using {command down}
        end tell
    end tell
    
    activate
    tell application "System Events"
        tell process "Finder"
            key code 0 using {command down}
        end tell
    end tell
    
    activate
    tell application "System Events"
        tell process "Finder"
            key code 49 using {option down}
        end tell
    end tell
end tell