I’ve created a crude Applescript for launching and controlling FrontRow. Although you can set the CD & DVD Preferences to open with FrontRow, if you want to automate what FrontRow does using Applescript this is one way to do it.
It uses an Automator workflow to launch FrontRow. To create such a workflow
Open a blank (“Custom”) workflow in Automator.
Click the Record button.
Do this key sequence very slowly to allow FrontRow time to react. You can always adjust the workflow playback speed later.
On the keyboard, hold down the Command key.
Hit the Escape key. Release the Command key and pause. (FrontRow should launch.)
Hold down the Command key again.
Hit the Escape key again.
Stop Automator recording.
Test the workflow. It should launch FrontRow but not exit it. (Hit Esc key to exit FrontRow.)
Save the workflow e.g. “LaunchFrontRow.workflow”
The workflow will not make any sense if you look at it, but it should work.
Next, write an Applescript to run the Automator workflow:
tell application "Automator"
activate
delay 1
end tell
tell application "System Events"
keystroke (ASCII character 13) -- keystroke Return key.
end tell
tell application "Automator"
set filePath to "Users:Username:[YourFilePath]:LaunchFrontRow.workflow"
open filePath
delay 3
end tell
tell application "System Events"
tell process "Automator"
tell menu bar 1
click menu bar item "Workflow"'s menu "Workflow"'s menu item "Run"
end tell
end tell
end tell
delay 8 -- waiting for FrontRow to launch
tell application "Automator" to quit with saving
tell application "System Events"
(*
Insert code to control FrontRow here.
*)
end tell
If Automator beeps or quits unexpectedly or if FrontRow fails to launch, try lengthening the delays. For a list of FrontRow keyboard shortcuts see: http://rgbdream.com/?p=52
To start a DVD automatically on insertion, set the “CD’s & DVD’s” preferences in System Preferences to run the Applescript on insertion. Then insert this code in the Applescript where indicated:
set returnKey to ASCII character 13
set escapeKey to ASCII character 27
set leftArrow to ASCII character 28
set rightArrow to ASCII character 29
set upArrow to ASCII character 30
set downArrow to ASCII character 31
keystroke upArrow
keystroke upArrow
keystroke upArrow
keystroke upArrow
keystroke upArrow
keystroke upArrow
keystroke upArrow
keystroke returnKey
If the Automator workflow becomes corrupted for some reason, it can be recreated.
Model: MacPro 8-core 3 GHz (2008), 2GB RAM
Browser: Opera/9.50 (Macintosh; Intel Mac OS X; U; en)
Operating System: Mac OS X (10.5)
Here’s an easier way to launch front row! This can be run directly as an applescript without using automator at all. Adjust the delay and keystrokes as needed.
set downArrow to ASCII character 31
tell application "System Events"
key code 53 using command down -- launch front row
delay 5 -- give front row time to launch, adjust as needed
tell process "FrontRow"
-- do whatever keystrokes you want next
keystroke downArrow
keystroke downArrow
end tell
end tell
The script works great but front row will start at whatever location it was stopped in ie itunes folder or movies folder.
How can I get front row to always open in the movies folder?
thanks
Well that doesn’t sound too hard. Basically just keystroke a bunch of characters once you are in frontrow to make sure you’re at the beginning menu. Then keystroke a bunch of up-arrows to make sure you’re at the top menu item in the beginning menu. Then from that known position you can count the down arrows and return-key presses you need to do to get to whatever menu item you want…
set downArrow to ASCII character 31
set upArrow to ASCII character 30
tell application "System Events"
key code 53 using command down -- launch front row
delay 5 -- give front row time to launch, adjust as needed
tell process "FrontRow"
-- this will make sure you are at the beginning menu.
-- It's the same as keystroking the escape key.
-- do it as many times as you feel necessary, 5 is just an example number
repeat 5 times
key code 53
delay 0.2
end repeat
-- this will make sure you are at the top of the beginning menu
-- do it as many times as you feel necessary, 5 is just an example number
repeat 5 times
keystroke upArrow
delay 0.2
end repeat
-- add here the appropriate keystrokes to get where you want from that known position
end tell
end tell
What does the escape loop do? I am assuming that when you start front row you are in the main browser window. Is there another possibility? This is the script I used and it worked fine.
set downArrow to ASCII character 31
set upArrow to ASCII character 30
set returnKey to ASCII character 13
tell application "System Events"
key code 53 using command down -- launch front row
delay 5 -- give front row time to launch, adjust as needed
tell process "FrontRow"
-- this will make sure you are at the beginning menu.
-- It's the same as keystroking the escape key.
-- do it as many times as you feel necessary, 5 is just an example number
-- this will make sure you are at the top of the beginning menu
-- do it as many times as you feel necessary, 5 is just an example number
repeat 6 times
keystroke upArrow
delay 0.2
end repeat
keystroke returnKey
delay 2 -- add here the appropriate keystrokes to get where you want from that known position
repeat 6 times
keystroke upArrow
delay 0.2
end repeat
keystroke downArrow
keystroke downArrow
delay 1
keystroke returnKey
end tell
end tell
on LaunchFrontRow(FrontRowAction)
try
tell application "System Events"
-- Launch FrontRow and wait for its loading
key code 53 using command down
delay 2
if (FrontRowAction = "PlayDVD") then
tell process "FrontRow"
repeat 8 times
keystroke upArrow
delay 0.2
end repeat
keystroke returnKey
end tell
end if
end tell
return
end try
end LaunchFrontRow
When I put
LaunchFrontRow("PlayDVD")
only FrontRow opens but there is no any keystroke simulation…
The reason was in the definition of keys in body of handler. So the correct one is:
on LaunchFrontRow(FrontRowAction)
set returnKey to ASCII character 13
set escapeKey to ASCII character 27
set leftArrow to ASCII character 28
set rightArrow to ASCII character 29
set upArrow to ASCII character 30
set downArrow to ASCII character 31
try
tell application "System Events"
-- Launch FrontRow and wait for its loading
key code 53 using command down
delay 2
if (FrontRowAction = "PlayDVD") then
tell process "FrontRow"
repeat 8 times
keystroke upArrow
delay 0.2
end repeat
keystroke returnKey
end tell
end if
end tell
return
end try
end LaunchFrontRow
wrapping a whole script with a try block while developing is very counterproductive,
because you’ll never get any error message if something goes wrong
Is there an command/key to simulate the “menu” button for Front Row to go back a screen using AppleScript?
I have all the others working. I thought it may be just the esc key but that quits the app.