DVD playerの04Go To Time....scpt (Apple Sample Code, Written
by Cary Dean)
にお世話になりました。サブルーティーンはまんま使ってあります。スクリプトに興味のある方のためにじっさいのスクリプトをのせておきます。
DVDtoExcel.scpt
on ConvertTimeToString(inTime)
-- break the time up into hours, minutes, and seconds
set timeVal to inTime
set numHours to (timeVal div hours)
set timeVal to timeVal - (numHours * hours)
set numMinutes to (timeVal div minutes)
set numSeconds to timeVal - (numMinutes * minutes)
-- now put together the string in the proper format adding preceding zeros if necessary
set timeStr to "" as string
-- hours
if (numHours < 10) then set timeStr to "0"
set timeStr to (timeStr & numHours)
-- minutes
set timeStr to (timeStr & ":")
if (numMinutes < 10) then set timeStr to (timeStr & "0")
set timeStr to (timeStr & numMinutes)
-- seconds
set timeStr to (timeStr & ":")
if (numSeconds < 10) then set timeStr to (timeStr & "0")
set timeStr to (timeStr & numSeconds)
return (timeStr as string)
end ConvertTimeToString
tell application "DVD Player"
set inTime to elapsed time
end tell
set sTime to ConvertTimeToString(inTime)
tell application "Microsoft Excel"
Select Range "R3C1"
Insert EntireRow of Selection
set selectedrow to (Row of ActiveCell) as text
set selectedcell to "R" & selectedrow & "C1"
set NumberFormatLocal of Selection to "@"
set FormulaR1C1 of Cell selectedcell to sTime
end tell
----------------------------------------------------
ExceltoDVD.scpt
property kInvalidTime : -1002
property kTimeDelimiter : ":"
on ConvertStringToTime(inStr)
try
set numHours to 0
set numMinutes to 0
set numSeconds to 0
-- store off the old delimiter
set oldDelimiters to AppleScript's text item delimiters
-- set the delimiter to ":"
set AppleScript's text item delimiters to kTimeDelimiter
set numItems to count of (text item of inStr)
if (numItems is equal to 1) then
set numSeconds to (text item 1 of inStr)
else if (numItems is equal to 2) then
set numMinutes to (text item 1 of inStr)
set numSeconds to (text item 2 of inStr)
else if (numItems is equal to 3) then
set numHours to (text item 1 of inStr)
set numMinutes to (text item 2 of inStr)
set numSeconds to (text item 3 of inStr)
else
error number kInvalidTime
end if
-- convert the time to secs
set numSecs to (numHours * hours) + (numMinutes * minutes) + numSeconds
-- reset the delimiter
set AppleScript's text item delimiters to oldDelimiters
on error errNum
set AppleScript's text item delimiters to oldDelimiters
error number kInvalidTime
end try
return (numSecs)
end ConvertStringToTime
tell application "Microsoft Excel"
set selectedrow to (Row of ActiveCell) as text
set selectedcell to "R" & selectedrow & "C1"
set sTime to FormulaR1C1 of Cell selectedcell
end tell
set inTime to ConvertStringToTime(sTime)
tell application "DVD Player"
set elapsed time to inTime
play dvd
end tell