PDA

View Full Version : Applescript / image mounting help




jdr999
Mar 14, 2007, 02:51 PM
I'm trying to create a script to open disk images, change the screen resolution, run an application, then eject the images and reset the desktop resolution.

I don't know why but I can't this to work reliably. Anyone have any ideas?

property myPath : "Macintosh HD:Users:Shared:Disk Images:"
property myApp : myPath & "Reader Rabbit Storybook"
property myTask : "TLClauncher"

property diskname1 : "RRERLS Disk1"
property diskISO1 : myPath & "Reader Rabbit Storybook.iso"

property diskname2 : ""
property diskISO2 : ""

on idle
tell application "System Events" to set myProcesses to (name of every process)
if myTask is not in myProcesses then
tell application "Finder"
if exists (disk diskname1) then eject diskname1
if not (diskname2 = "") then
if exists (disk diskname2) then eject diskname2
end if
end tell
do shell script "cscreen -x 1920 -y 1200 -r 60"
tell me to quit
end if
return 2
end idle

on run
tell application "Finder"

if not (exists the disk diskname1) then
do shell script ("hdiutil attach " & quoted form of
POSIX path of (diskISO1 as string) & " -mount required -noverify")
repeat until name of every disk contains diskname1
delay 1
end repeat
end if

if not (diskname2 = "") then
if not (exists the disk diskname2) then
do shell script ("hdiutil attach " & quoted form of
POSIX path of (diskISO2 as string) & " -mount required -noverify")
repeat until name of every disk contains diskname2
delay 1
end repeat
end if
end if

end tell

do shell script "cscreen -x 640 -y 480 -r 60"
tell application myApp to activate
idle
end run