Desktop Slideshow Question

“Trashman” posted this great script for a desktop slidshow which I’ve been playing with.

When I send a stop command to this script, it cycles through the remaining photos before stopping (albeit quickly). Any idea how to get it to stop mid-cycle (the “on error” command is not working).

Also, this only loops through the photos once. Anyway to continue the loop?

tell application "Finder"
	activate
	set picturefolder to "CG:Users:Me:Desktop:MyPhotos:folderofpics" -- path to folder of pictures
	set desktop_picture_old to (desktop picture) as alias
	set filecount to number of files in folder picturefolder
	try
		repeat with i from 1 to filecount
			try
				set desktop picture to file index i of folder picturefolder
				delay 8
				
			end try
		end repeat		
	on error
		set desktop picture to desktop_picture_old
	end try
	set desktop picture to desktop_picture_old
	
end tell

Thanks,
Jet
:smiley:

In this case, I believe “Trash Man” is me (it’s complicated but suffice it to say that as the admins have improved these forums, some posts lost their affiliation for one reason or another; to keep the posts, the generic “Trash Man” account is listed as the author for those posts regardless of who actually was the original author). In any event, try this revised code (note: the image types are probably not exhaustive of what the Finder can actually display):

property slide_delay : 8

set picture_folder to (choose folder with prompt "Locate a folder full of images for slide show:") as Unicode text
my desktop_slideshow(picture_folder)

on desktop_slideshow(picture_folder)
	tell application "Finder"
		set desktop_picture_old to (desktop picture) as alias
		try --so if you cancel out of the script or if the folder is empty:
			repeat with i in (get files in folder picture_folder)
				set i to i as alias
				if (my is_file_an_image(i)) then
					set desktop picture to i
					delay slide_delay
				end if
			end repeat
		end try
		set desktop picture to desktop_picture_old
	end tell
end desktop_slideshow

--the following lists are probably not exhaustive of what the Finder can display:
property image_types : {"8BPS", "EPSf", "GIF ", "JPEG", "JPG ", "PDF ", "PDFf", "PIC ", "PICT", "PNG ", "PNGf", "TIF ", "TIFF"}
property image_extensions : {"psd", "eps", "epsf", "gif", "jpeg", "jpg", "pdf", "pic", "pict", "picture", "png", "pngf", "tif", "tiff"}

on is_file_an_image(the_file)
	tell (info for the_file) to return ((get file type) is in image_types) or ((get name extension) is in image_extensions)
end is_file_an_image

Jon

Sorry about that guys.

Jon would be correct. Our policy rules have changed (which we feel for the better) when we updated the board this year. In short, un-qualified profiles are no more.

Member profiles which we are unable to validate are deleted entirely. We didn’t want to delete the posts as they have value. On the other hand, we couldn’t leave the member profiles unqualified either. This presented a quandry in how we treated those posts that member had made.

The way we got around this is by creating a new ‘dummy’ account [Trash Man], whose sole purpose is to throw all of those posts into before we delete that member.

We migrated Code Exchange from a different section on Macscripter to this BBS, which Jon had posted previously to as well. Those members were brought over from a totally different database. Hence, the combination of both these issues, and therefore the unfortunate consequence of some of his posts from Code Exchange showing up in Trash Man. :rolleyes:

Jon –

Thanks so much for your help. That code works really well and is very helpful. Its also good to know that no one chose the name “Trash man”.

I still am having one little problem. I’m trying to switch between three different slideshow scripts by putting “quit” commands at the beginning of each script to kill the other two before launching that script’s slideshow. I’m triggering the scripts from a Java app based on an external input.

Somehow though, the apps are getting stalled in the “quitting” process so the pics are overlapping again. Hitting the “stop” button while these scripts are in script editor works perfectly. So, I was wondering, is there anyway to trigger the “stop button” of a script from an external script?

I’m using this code ahead of the slideshow code:

try
tell application “Aslideshow”
quit without saving
end tell
end try

try
tell application “Bslideshow”
quit without saving
end tell
end try


Thanks,
Jet

Why have three separate applications? Since the code is in a handy handler, try this:

property slide_delay : 8
property desktop_picture_old : missing value

my desktop_slideshow("path:to:picture folder 1:")
my desktop_slideshow("path:to:picture folder 2:")
my desktop_slideshow("path:to:picture folder 3:")

on desktop_slideshow(picture_folder)
	tell application "Finder"
		if desktop_picture_old = missing value then set desktop_picture_old to (desktop picture) as alias
		try --so if you cancel out of the script or if the folder is empty:
			repeat with i in (get files in folder picture_folder)
				set i to i as alias
				if (my is_file_an_image(i)) then
					set desktop picture to i
					delay slide_delay
				end if
			end repeat
		end try
		set desktop picture to desktop_picture_old
		set desktop_picture_old to missing value
	end tell
end desktop_slideshow

--the following lists are probably not exhaustive of what the Finder can display:
property image_types : {"8BPS", "EPSf", "GIF ", "JPEG", "JPG ", "PDF ", "PDFf", "PIC ", "PICT", "PNG ", "PNGf", "TIF ", "TIFF"}
property image_extensions : {"psd", "eps", "epsf", "gif", "jpeg", "jpg", "pdf", "pic", "pict", "picture", "png", "pngf", "tif", "tiff"}

on is_file_an_image(the_file)
	tell (info for the_file) to return ((get file type) is in image_types) or ((get name extension) is in image_extensions)
end is_file_an_image

Jon

Hi Jon,

Thanks again for your help. I really appreciate it. I guess I should clarify that I’ve got three seperate apple scripts with a bunch of other code in them as well. The slideshow is just one part of it. The Java code is actually where I launch each seperate script, so I either need to kill the scripts in Java before launching a different one, or find a way to do it in applescript at the head of each script. That’s why I was asking about how to “stop” a script. I have a feeling it may be more “pure” to do it in java, but I thought if there was a simple solution in applescript I would try that first. I only know how to code in Processing (psuedo Java) right now so I’m just learning Applescript and real Java.

Thanks,
Jet