I’m not at all experienced in scripting, but after Leopard broke a favourite app of mine I attempted to build a replacement for it out with AppleScript. Its function is to make a video and allow me to take notes at the same time. Each note is inserted into the video as a chapter. I use it in theatre rehearsals so that I can take notes on complex dance routines without having to worry about which moment of the routine the note refers to. All I do is play the video back, go to each chapter heading and do my note. I know that the final stages of the script are very crude, and I have to do some things manually, as I couldn’t get the script to do them for me, but as I said, I’m not a scripter, and as soon as I got the script to work, I went back to my day job!
Now Snow Leopard has broken my script, and I have a technical rehearsal starting on Saturday! I know that date and time handling have changed, but I can’t for the life of me see how to fix it. Can anyone help with this? It only works with QT pro, btw. I hope I’ve posted this correctly, but please forgive me if I’ve got the posting wrong, it’s not clear to me how to work the applescript button.
Many thanks.
Ben
set listofnotes to {}
tell application “QuickTime Player 7”
activate
new movie recording
start first recording
end tell
set thought to “note”
set startTime to time of (current date)
set the_file_path to “June 10:Users:benormerod:movies: show movies:listofnotes.txt”
open for access file the_file_path with write permission
set eof file the_file_path to 0
write “{QTtext}{font:Geneva}{plain}{size:12}{textColor: 65535, 65535, 65535}{backColor: 0, 0, 0}{justify:center}{timeScale:1000}{width:160}{height:48}{timeStamps:absolute}{language:0}{textEncoding:0}” & return to file the_file_path
close access file the_file_path
repeat
set the_button to button returned of (display dialog “click to note” buttons {“stop”, “note”} default button 2)
if the_button is “stop” then exit repeat
set EndTime to time of (current date)
display dialog "enter your note" default answer thought
set thought1 to text returned of the result
set duration to EndTime - startTime - 1
--reformat duration
set x to date ("0" as string)
set hours of x to duration div hours
set minutes of x to duration mod hours div minutes
set seconds of x to duration mod hours mod minutes
set currentnote to "[" & time string of x & ".000" & "]" & return & thought1 & return
open for access file the_file_path with write permission
write currentnote to file the_file_path starting at eof
close access file the_file_path
end repeat
set EndTime to time of (current date)
set duration to EndTime - startTime - 1
–reformat duration
set x to date (“0” as string)
set hours of x to duration div hours
set minutes of x to duration mod hours div minutes
set seconds of x to duration mod hours mod minutes
set currentnote to “[” & time string of x & “.000” & “]” & return & “end” & return
open for access file the_file_path with write permission
write currentnote to file the_file_path starting at eof
close access file the_file_path
tell application “QuickTime Player 7”
stop first recording
activate
open the_file_path
select all
tell application "System Events" to keystroke "c" using command down
tell application "System Events" to keystroke "w" using command down
tell application "System Events" to keystroke "v" using {command down, option down}
tell application "System Events" to keystroke "j" using command down
end tell
then I have to manually click a a few buttons to associate the chapter text with the video. One day I’d like to fix that too, but at the moment the really urgent thing is this…
tell application “QuickTime Player 7”
activate
new movie recording current application
start recording 1
end tell
tell current application
current date
→ date “Wednesday, 16 March 2011 11:10:41”
open for access file “June 10:Users:benormerod:movies: show movies:listofnotes.txt” with write permission
→ 224
set eof file “June 10:Users:benormerod:movies: show movies:listofnotes.txt” to 0
write "{QTtext}{font:Geneva}{plain}{size:12}{textColor: 65535, 65535, 65535}{backColor: 0, 0, 0}{justify:center}{timeScale:1000}{width:160}{height:48}{timeStamps:absolute}{language:0}{textEncoding:0}
" to file “June 10:Users:benormerod:movies: show movies:listofnotes.txt”
close access file “June 10:Users:benormerod:movies: show movies:listofnotes.txt”
end tell
tell application “AppleScript Editor”
display dialog “click to note” buttons {“stop”, “note”} default button 2
→ {button returned:“note”}
end tell
tell current application
current date
→ date “Wednesday, 16 March 2011 11:11:05”
end tell
tell application “AppleScript Editor”
display dialog “enter your note” default answer “note”
→ {text returned:“note”, button returned:“OK”}
Result:
error “Invalid date and time date 0 of «script».” number -30720
Model: MacBook Intel core 2 duo
AppleScript: 2.1.2
Browser: Firefox 3.6.15
Operating System: Mac OS X (10.6)