Search code examples
applescriptslideshow

Dynamic Slideshow using Applescript


I have a folder of images that gets updated from a camera taking pictures periodically throughout the day. I'm trying to write some applescript that will create a slideshow from a folder of images but also update as more are added without having to rerun the script. I started out trying to do quick look but couldn't get that working. Any ideas on how best to tackle this?

UPDATE this is what I have hacked together so far:

tell application "Finder" to set the_folder to get folder (choose folder)
tell application "Finder" to open the_folder

tell application "System Events"
    tell process "Finder"
        key code 124
        keystroke "a" using command down
        keystroke " " using option down
    end tell
end tell

I don't believe this works if I add photos behind the scenes though.


Solution

  • This is what I came up with and it works perfectly for what I need.

    tell application "Finder" to set the_folder to get folder (choose folder)
    tell application "Finder" to open the_folder
    
    tell application "System Events"
        tell process "Finder"
            key code 124
            keystroke "a" using command down
            keystroke " " using option down
        end tell
    end tell
    
    repeat while true
        delay 60
        tell application "System Events"
            tell process "Finder"
                keystroke "a" using command down
            end tell
        end tell
    end repeat
    

    A few caveats... since it is using quick look, you can't really do anything on the computer while this is running since it can't have any other app activate while it is running (quick look closes when this happens). Also the repeat section is required to get quick look to pickup the new additions to the directory without losing focus. Pretty nasty stuff, but I couldn't really find another easy way to do it!