ActionScript called by AppleScript in ImageReady CS2 fail close window

I am trying to script ImageReady CS2. I know it is very limited, but I have an ActionScript that works fine to do what I need. I can call on the ActionScript without error, but I can not get ImageReady to close the file. I have tried a variety of locations and syntax to no avail. I hope I am not asking for too much from AppleScript on this one, it seems simple. System Events should be able to handle this, but fails in ImageReady where other apps handle the command just fine. Any thoughts?

thanks,
Levon


set FileSample to choose folder with prompt "Please select an input folder."
set folderName to name of (info for FileSample)
tell application "Finder" to set theFiles to files of folder FileSample whose name extension is in {"eps", "psd"} or kind contains "Adobe Photoshop EPS file" or kind contains "EPS" or kind contains "Photoshop" or kind contains "PSD"
repeat with oneFile in theFiles
	tell application "Adobe ImageReady CS2"
		activate
		open (oneFile as alias)
		tell front document
			do script "Save as GIF Optimized" with delay 1
			tell application "System Events" to keystroke "w" using command
		end tell
	end tell
end repeat

Model: Dual 2.3GHz G5
AppleScript: 2.1.1/Script Debugger 4
Browser: Firefox 2.0.0.6
Operating System: Mac OS X (10.4)

Update: After thinking about just saving the ActionScript as a Droplet and calling it from AppleScript, I was pointed to the ‘tell System Events’ line. This works fine now. Its not all AppleScript, but its vanilla enough for me and it is still quick and easy.


set FileSample to choose folder with prompt "Please select an input folder."
set folderName to name of (info for FileSample)
tell application "Finder" to set theFiles to files of folder FileSample whose name extension is in {"eps", "psd"} or kind contains "Adobe Photoshop EPS file" or kind contains "EPS" or kind contains "Photoshop" or kind contains "PSD"
repeat with oneFile in theFiles
    tell application "Adobe ImageReady CS2"
        activate
        open (oneFile as alias)
        tell front document
            do script "Save as GIF Optimized"
            tell application "System Events" to tell process "Adobe ImageReady  
CS2" to keystroke "w" using command down
        end tell
    end tell
end repeat

Model: Dual 2.3GHz G5
AppleScript: 2.1.1/Script Debugger 4
Browser: Firefox 2.0.0.6
Operating System: Mac OS X (10.4)

Not sure but are the SFW options that are included in Photoshop CS2 not going to give you what you require? Image Ready bites the bullet in CS3 I think.

I found a problem with a file in the ImageReady package:
/Applications/Adobe Photoshop CS2/Adobe ImageReady CS2.app/Contents/Resources/ ImageReady Batch Log.txt
I trash it and all is well. The first user to launch the app writes their permissions to the file, no one else has access. Hence the permission error running ActionScripts.

Model: Dual 2.3GHz G5
AppleScript: 2.1.1/Script Debugger 4
Browser: Firefox 2.0.0.6
Operating System: Mac OS X (10.4)