This is my first AppleScript that works well, but looks messy. How can I clean this up?
-- Activate USB to RS232 serial device in terminal screen.
tell application "Terminal"
activate
do script "screen /dev/cu.usbserial"
end tell
delay 2
-- Turn on TV power from standby mode 1 only, go to computer, and quit terminal screen.
tell application "System Events"
keystroke "POWR1 "
keystroke return
delay 1
keystroke "IAVD5 "
keystroke return
delay 1
keystroke "a" using control down
keystroke "k"
keystroke "y"
delay 1
quit application "Terminal"
end tell
delay 1
-- Activate VirtualDVHS HD recorder.
tell application "VirtualDVHS" to activate
-- Make sure HD recorder is already stopped if previously playing.
tell application "System Events"
tell application process "VirtualDVHS"
click button 11 of window "VirtualDVHS - Version 2.15"
end tell
end tell
delay 1
-- Activate USB to RS232 serial device in terminal screen again.
tell application "Terminal"
activate
do script "screen /dev/cu.usbserial"
end tell
delay 2
-- Change to Channel 4.1, and quit terminal screen.
tell application "System Events"
keystroke "DA2P0401"
keystroke return
delay 1
keystroke "a" using control down
keystroke "k"
keystroke "y"
delay 1
quit application "Terminal"
end tell
delay 1
-- Start recording on channel 4.1 for 30 minutes.
tell application "System Events"
tell application process "VirtualDVHS"
click button 12 of window "VirtualDVHS - Version 2.15"
end tell
end tell
delay 1800
-- Stop recording on channel 4.1 after 30 minutes.
tell application "System Events"
tell application process "VirtualDVHS"
click button 11 of window "VirtualDVHS - Version 2.15"
end tell
end tell
delay 1
-- Activate USB to RS232 device in terminal screen again.
tell application "Terminal"
activate
do script "screen /dev/cu.usbserial"
end tell
delay 2
-- Go to computer, turn off TV power from standby 1 mode, and quit terminal screen.
tell application "System Events"
keystroke "IAVD5 "
keystroke return
delay 1
keystroke "POWR0 "
keystroke return
delay 1
keystroke "a" using control down
keystroke "k"
keystroke "y"
delay 1
quit application "Terminal"
end tell