Pushing the automation - Applescript and Toast Titanium

I went within the forum to see if there was a way to automize this process even further and I found some applescript lines which gets Toast to start burning a DVD.

I’ve included the lines into my script and everything works until it’s time to click the “Enter” button for the burn process to start.

The window where I need to press enter is showing up. In french I’ve got three buttons (Close the drawer, Cancel and Burn - Fermer le tiroir, Annuler and Graver).

Does someone has an idea why the the keystroke “return” is not actioned?

set InvoiceNo to ""

repeat while InvoiceNo is not equal to 9999
	set {text returned:InvoiceNo, button returned:buttonReturned} to display dialog "Please enter Invoice Number or 9999 to quit:" buttons {"Change Invoice No", "OK"} default button 2 default answer InvoiceNo -- each picture are only 4 character long
	set files_to_add to (path to home folder as text) & "Customer:NIK0" & InvoiceNo & ".MPG"
	
	if buttonReturned is "Change Invoice No" then
		set InvoiceNo to ""
	else
		if InvoiceNo is equal to "9999" then
			exit repeat
		end if
		
		tell application "Toast Titanium"
			set toast_project to current disc
			add to toast_project items {files_to_add as alias}
		end tell
	end if
end repeat
tell application "Toast Titanium"
	write toast_project with asynchronous completion without asking
	tell application "System Events"
		tell process "Toast Titanium"
			keystroke return
		end tell
	end tell
end tell

In addition is there a way to select options from the Toast Titanium Menu bar and activate them. For example, once the DVD is burned I would like to select all video files and then remove them?

In some occasion I may even want to go further i.e go between Video and Convert option . For some files I may just want to create a DVD with the encoding parameter equal to “Never” In other occasion I may just want to convert the video files into iPod, PSP files.

My priority at this moment is to automate as much as possible the creation of DVD. I’ve contacted the Toast development team and asked them if there was a way to run Toast in Batch mode. Their response was no, this is why I am trying to perform those actions using the Applescropt.

Am I pushing it to far?

MANY THANKS!!!

Regards!
Daniel

I got it to work by adding to instances of delay and one keystroke return.

set InvoiceNo to ""

repeat while InvoiceNo is not equal to 9999
	set {text returned:InvoiceNo, button returned:buttonReturned} to display dialog "Please enter Invoice Number or 9999 to quit:" buttons {"Change Invoice No", "OK"} default button 2 default answer InvoiceNo -- each picture are only 4 character long
	set files_to_add to (path to home folder as text) & "Customer:NIK0" & InvoiceNo & ".MPG"
	
	if buttonReturned is "Change Invoice No" then
		set InvoiceNo to ""
	else
		if InvoiceNo is equal to "9999" then
			exit repeat
		end if
		
		tell application "Toast Titanium"
			set toast_project to current disc
			add to toast_project items {files_to_add as alias}
		end tell
	end if
end repeat
delay 7
tell application "Toast Titanium"
	write toast_project with asynchronous completion without asking
	tell application "System Events"
		tell process "Toast Titanium"
			keystroke return
			delay 4
			keystroke return
		end tell
	end tell
end tell

Hi Daniel, I’m using the following script and don’t need to use System Events at all:

set multiliste to {}
set firstprompt to “Choisir le 1er fichier à graver sur CD”
set multifichier to true
set pdfwarning to alias “Macintosh HD:Users:scyr:Desktop:Visuels et FTP snap:IMPORTANT_PDFX1a_INFO.txt”
repeat while multifichier is true
set filetoadd to (choose file with prompt firstprompt) as alias
display dialog “Y’a-t’il d’autres fichiers à graver?” buttons {“Oui”, “Non”} default button 2
if button returned of the result is not “Oui” then set multifichier to false
set multiliste to multiliste & filetoadd as list
set firstprompt to “Choisir le fichier suivant à graver sur CD”
end repeat
set filelist to pdfwarning & multiliste as list

tell application “Toast Titanium”
activate
set mynewdisc to (make new Data disc with properties {file system type:Mac OS Standard Hybrid, name:“Disque Mac”})
set my_disc to current disc
add to my_disc items filelist
write CD without asking and ejecting
end tell

Or, you can use:

keystroke “d” using command down
keystroke return

Hi,

I’m having similar problems;

error "Toast Titanium got an error: Can't get keystroke \"
\"." number -1728 from keystroke "
"

. . . . . no correct that:-
Just recompiled using - keystroke “d” using command down - (in addition to keystroke return) and it seems to work :

tell application "Toast Titanium"
	open theFile
	set toast_project to current disc
	add to toast_project items files_to_add
	delay 10
	write toast_project with asynchronous completion, verification, ejecting and quitting without asking
end tell
tell application "System Events"
	tell process "Toast Titanium"
		keystroke "d" using command down
		keystroke return
	end tell
end tell

Thanks for that!