GPinzone Posted November 17, 2010 Posted November 17, 2010 My Primera Bravo II duplicator comes with a program called PrimoDVD. You can use it to print multiple copies of discs, print labels, etc. However, it has some surprising limitations. For example, let's say your company has a software package consisting of 3 discs. You'd like to be able to click a button and have the duplicator get those three ISO files, three label files, and create a set of discs for you. PrimoDVD has no such ability. You need to create jobs for each disc every time.To automate this, I use AutoIt to create an API that can control PrimoDVD and allow individual au3 files for each software set you want duplicated.Here's the API called "Disc Duplicator Function Libraries.au3":expandcollapse popup; ; AutoIt Version: 3.0 ; Language: English ; Platform: XP Professional ; Author: Gerard Pinzone (gpinzone AT yahoo.com) ; ; Script Function: ; Automates creation of CD/DVD sets for PrimoDVD. ; #include <INet.au3> Func processJobs($Title, $arr) Local $TimeStamp, $DupeTime Local $NumSets, $DiscSet, $QueueSize ; Store the time the process begins $TimeStamp = TimerInit() ; Exit script if PrimoDVD is already running If ProcessExists("PrimoDVD.exe") Then MsgBox(0, "AutoIt", "PrimoDVD is already running.") Exit EndIf ; Disable Screen Saver disableScreenSaver() ; Get number of sets from the command-line $NumSets = getNumSets() ; Repeat process for each set of discs For $DiscSet = 1 to $NumSets ; Run the PrimoDVD software Run("C:\Program Files\PrimoDVD (English)\PrimoDVD.exe") ; Wait for the PrimoDVD become active - it is titled "PrimoDVD 2.1 for Disc Publisher PRO, II, or XR" on English systems WinWaitActive("PrimoDVD 2.1 for Disc Publisher PRO, II, or XR") ; Find size of Queue $QueueSize = UBound( $arr, 1) ; Add jobs onto the queue For $i = 0 to $QueueSize - 1 QueueJob($arr[$i][0], $arr[$i][1]) Next ; Clear all prompts when jobs are done ClearJobCompletePrompts($QueueSize) ; Now quit by sending a "close" request to the calc WinClose("PrimoDVD 2.1 for Disc Publisher PRO, II, or XR") ; Do not save jobs ClearJobSavePrompts($QueueSize) ; Now wait for PrimoDVD to close before continuing WinWaitClose("PrimoDVD 2.1 for Disc Publisher PRO, II, or XR") Next ; Enable Screen Saver enableScreenSaver() ; Calculate how long the process took $DupeTime = CalcDupeTime(TimerDiff($TimeStamp)) sendEmail($Title, $NumSets, $DupeTime) EndFunc Func getNumSets() Local $NumSets ; Check command line If $CmdLine[0] > 0 Then If $CmdLine[1] > 0 Then $NumSets = $CmdLine[1] Else MsgBox(0, "PrimoDVD AutoIt Script", "Number of jobs must be 1 or more.") Exit EndIf Else ; Initialize number of sets to 1 as default $NumSets = 1 EndIf Return $NumSets EndFunc Func QueueJob($label, $discimg) ; Start Global Image job Send("^i", 0) ; Set Disc Label Send("!p{TAB}" & $label & "{ENTER}", 0) ;Set Disc Image Send("!i" & $discimg & "{ENTER}", 0) ; Start job Send("{F6}", 0) EndFunc Func ClearJobCompletePrompts($NumPrompts) Local $i For $i = 1 to $NumPrompts WinWaitActive("PrimoDVD 2.1") ; Keep polling for prompts While (StringStripWS(WinGetText("PrimoDVD 2.1", ""), 3) <> "OK") Sleep(500) WEnd ; Send ENTER to get rid of OK prompt Send("{ENTER}", 0) Next EndFunc Func ClearJobSavePrompts($NumPrompts) Local $i For $i = 1 to $NumPrompts WinWaitActive("PrimoDVD 2.1") ; Keep polling for prompts While (StringStripWS(WinGetText("PrimoDVD 2.1", ""), 8) <> "Cancel&No&Yes") Sleep(500) WEnd ; Choose "No" to get rid of prompt Send("n", 0) Next EndFunc Func OpenPrompt($message) Local $answer ; Prompt the user to run the script - use a Yes/No prompt (4 - see help file) $answer = MsgBox(4, "PrimoDVD AutoIt Script", "This script will run the PrimoDVD and burn job " & $message & ". Run?") ; Check the user's answer to the prompt (see the help file for MsgBox return values) ; If "No" was clicked (7) then exit the script If $answer = 7 Then MsgBox(0, "AutoIt", "OK. Bye!") Exit EndIf EndFunc Func CalcDupeTime($iTimestampDiff) Local $iSeconds = Int($iTimestampDiff / 1000) Local $iHours, $iMins, $iSecs $iHours = Int($iSeconds / 3600) $iSeconds = Mod($iSeconds, 3600) $iMins = Int($iSeconds / 60) $iSecs = Mod($iSeconds, 60) If StringLen($iHours) = 1 Then $iHours = "0" & $iHours If StringLen($iMins) = 1 Then $iMins = "0" & $iMins If StringLen($iSecs) = 1 Then $iSecs = "0" & $iSecs Return $iHours & ":" & $iMins & ":" & $iSecs EndFunc Func sendEmail($Title, $NumSets, $DupeTime) Local $s_SmtpServer = "192.168.1.30" Local $s_FromName = "Primo Disc Duplicator" Local $s_FromAddress = "Primo@yahoo.com" Local $s_ToAddress = "UserName@yahoo.com" Local $s_Subject = "[DUPLICATOR] - " & $Title & " - " & $NumSets & " set(s) in " & $DupeTime Local $as_Body[2] $as_Body[0] = "The job took " & $DupeTime & " to complete." Local $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, 1, -1) Local $err = @error If $Response = 1 Then ;MsgBox(0, "Success!", "Mail sent") Else ;MsgBox(0, "Error!", "Mail failed with error code " & $err) EndIf EndFunc Func toggleScreenSaver() Local $key = "HKEY_CURRENT_USER\Control Panel\Desktop" Local $value = "ScreenSaveActive" If Number(RegRead($key, $value)) Then RegWrite($key, $value, "REG_SZ", 0) Else RegWrite($key, $value, "REG_SZ", 1) EndIf EndFunc Func disableScreenSaver() Local $key = "HKEY_CURRENT_USER\Control Panel\Desktop" Local $value = "ScreenSaveActive" If Number(RegRead($key, $value)) Then RegWrite($key, $value, "REG_SZ", 0) EndIf EndFunc Func enableScreenSaver() Local $key = "HKEY_CURRENT_USER\Control Panel\Desktop" Local $value = "ScreenSaveActive" If Number(RegRead($key, $value)) = 0 Then RegWrite($key, $value, "REG_SZ", 1) EndIf EndFuncHere's an example of a AutoIt script for a set of CDs/DVDs called "CEI 3.6 32-bit.au3":; ; AutoIt Version: 3.0 ; Language: English ; Platform: XP Professional ; Author: Gerard Pinzone (gpinzone AT yahoo.com) ; ; Script Function: ; Generates complete set(s) of discs. ; #include "U:\Macros\Disc Duplicator Function Libraries.au3" ; Title of job Local $Title = "CEI 3.6 32-bit (3 Discs)" ; Set up array of labels and images ; The max number of jobs in PrimoDVD is 32 Local $Queue [32][2] = [["U:\Disc Labels\CEI\CEI 3.6\32-bit\CEI 3.6 - Disc 1 of 3 - RHEL 5.2 32-bit DVD.std", "U:\Disc Images\CEI\CEI 3.6\32-bit\CEI 3.6 - Disc 1 of 3 - RHEL 5.2 32-bit DVD.gi"], _ ["U:\Disc Labels\CEI\CEI 3.6\32-bit\CEI 3.6 - Disc 2 of 3 - CEI COTS 32-bit DVD.std", "U:\Disc Images\CEI\CEI 3.6\32-bit\CEI 3.6 - Disc 2 of 3 - CEI COTS 32-bit DVD.gi"], _ ["U:\Disc Labels\CEI\CEI 3.6\32-bit\CEI 3.6 - Disc 3 of 3 - CEI Documentation 32-bit.std", "U:\Disc Images\CEI\CEI 3.6\32-bit\CEI 3.6 - Disc 3 of 3 - CEI Documentation 32-bit.gi"]] Local $i ; Trim the Queue array down to actual size For $i = 0 To UBound( $Queue, 1) - 1 If $Queue[$i][0] = "" Then ReDim $Queue[$i][2] ExitLoop EndIf Next ; Display DVD warning OpenPrompt($Title & " - WARNING! DISC 1 & 2 ARE DVDs") ; Run main function processJobs($Title, $Queue)By clicking on the second AutoIt script, the program will start up, create three entries in the queue, load, print, and unload the discs, and send an email to let you know it's done. You can run it from the command line and specify a number of copies, too.NOTE: You need to change one option in PrimoDVD for this script to work: Tools, Options, View, and turn on the "Show Result message after a job ends." option. This is needed so AutoIt can determine when each disc has been burned. Gerard J. Pinzonegpinzone AT yahoo.com
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now