slideshow applescript help please

I am trying to make an Applescript to launch a slideshow from the finder, not an iPhoto slideshow, but the one you get by clicking the Tools button and selecting slideshow. It is much easier to choose which photos I want to save my computer by using that, but it is a pain to have to select all the photos, and then click multiple buttons to view it.

So I set out to create a script to select all the files in the folder, and start a slideshow. I am very close. I can click that button, but don’t know how to script the menu it displays when clicking the button. Much help would be appreciated.

Here is my script so far:

tell application "Finder"
	activate
	tell application "System Events"
		tell process "Finder"
			tell menu bar 1
				tell menu bar item "Edit"
					tell menu "Edit"
						click menu item "Select All"
					end tell
				end tell
			end tell
		end tell
	end tell
end tell
tell application "System Events"
	tell process "Finder"
		tell window 1
			tell tool bar 1
				tell group 2
					tell menu button 1
						click
					end tell
				end tell
			end tell
		end tell
	end tell
end tell

Model: Macbook 13", 2.0 GHZ, 80 GB HDD, 2 GB RAM
Browser: Camino 1.1 beta
Operating System: Mac OS X (10.4)

I don’t seem to have a “tools” menu pick in the Finder, but you can certainly make your select all briefer:


activate application "Finder"
tell application "System Events" to tell process "Finder" to keystroke "a" using command down

Hi,

scripting menu button is very unsatisfying,
because unlike popup button the menu items are not available as UI elements,
so you must perform keystrokes, which might cause problems to catch the right menu item

This works on my machine

activate application "Finder"
tell application "System Events" to tell process "Finder"
	keystroke "a" using command down
	tell menu button 1 of group 2 of tool bar 1 of window 1
		click
		delay 0.2
		key code {125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 49} -- slideshow is 10th menu element
	end tell
end tell

I’m obviously missing something you have Stefan. When I run your script it selects all the images, then the first. Nothing else happens.

It’s 11th for me. (However, your script does successfully make an archive. :P)

:stuck_out_tongue:

That’s why I can’t stand these kind of GUI poking.
Mostly you get instable results

Maybe this is of help. It plays images of the current finder window as a desktop slideshow (using Exposé to hide all other windows) with a given delay). Check you settings though; make sure to set the System Prefs’s Desktop Screen Effect to “Fit To Screen”, if you want to the whole picture, that is. At the end of the show your original desktop pic will occur again.

property theTypes : {"8BPS", "EPSf", "GIF ", "JPEG", "JPG ", "PDF ", "PDFf", "PIC ", "PICT", "PNG ", "PNGf", "TIF ", "TIFF", "TGA"}
property theExtensions : {"psd", "eps", "epsf", "gif", "jpeg", "jpg", "pdf", "pic", "pict", "picture", "png", "pngf", "tif", "tiff", "tga"}
property slideDelay : {0.6, 0.9, 1, 1.5, 2, 2.5, 3, 4, 5}
property downloadFolder : (path to downloads folder)

tell application "Finder"
	activate
	if not (exists front Finder window) then set target of (make new Finder window) to (choose folder with prompt "Choose a folder containing images..." default location (downloadFolder as text))
	set pictureFolder to (folder of front Finder window as text) as Unicode text
	set slideDelay to choose from list slideDelay OK button name "Play" cancel button name "Stop" default items 3
	if slideDelay is false then return
end tell

my desktopSlideshow(pictureFolder)

on desktopSlideshow(pictureFolder)
	tell application "Finder"
		set desktopPictureOld to (desktop picture) as alias
		try
			do shell script "/Applications/Utilities/Expose.app/Contents/MacOS/Expose 1"
			repeat with i in (get files in folder pictureFolder)
				set i to i as alias
				if (my thisIsAnImage(i)) then
					set desktop picture to i
					delay slideDelay
				end if
			end repeat
		end try
		set desktop picture to desktopPictureOld
		do shell script "/Applications/Utilities/Expose.app/Contents/MacOS/Expose 1"
	end tell
	set slideDelay to {0.6, 0.9, 1, 1.5, 2, 2.5, 3, 4, 5}
end desktopSlideshow

on thisIsAnImage(theFile)
	tell (info for theFile) to return ((get file type) is in theTypes) or ((get name extension) is in theExtensions)
end thisIsAnImage

Greetings, TwistIt.