Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Front Row Won't Work Nicely With AppleScript

Front Row Won't Work Nicely With AppleScript
Thread Tools
ncmason
Guest
Status:
Reply With Quote
Nov 17, 2007, 08:38 AM
 
So, I've got a script setup to open iTunes, start playing a song, and then show it in Front Row. It worked flawlessly in Tiger. For some reason, Front Row won't play well with the script in Mac OS X Leopard. Any ideas? Here's the script:

tell application "iTunes"
play playlist "Music"
end tell
tell application "System Events"
-- Command Esc. to start Front Row
key code 53 using command down
-- wait for Front Row to be ready for keyboard input
delay 4
-- Press Return twice (Music -> currently playing)
key code 36
key code 36
end tell
     
Junior Member
Join Date: Mar 2000
Location: Salem, OR, USA
Status: Offline
Reply With Quote
Nov 17, 2007, 07:13 PM
 
The old method isn't going to work anymore. I didn't play with Front Row under 10.4 so I can't speak with authority on how it used to work, but from the looks of your script I'd say that Front Row was really using iTunes via AppleScript. Under 10.5 it seems like Front Row has its own internal playback method. My reasoning for this is the following script.

- - - - - - - - - - - - - - - - - - - - - - - - - -

tell application "System Events"
-- Command Esc. to start Front Row
key code 53 using command down
-- wait for Front Row to be ready for keyboard input
delay 4
end tell

tell application "iTunes"
play playlist "Music"
end tell

tell application "System Events"
-- up arrow to guarantee top of menu
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
-- down arrow to get to Music
key code 125
key code 125
-- Press Return twice (Music -> currently playing)
key code 36
key code 36
end tell


- - - - - - - - - - - - - - - - - - - - - - - - - -

I found that if iTunes was playing when Front Row was invoked then iTunes would be told to stop playing. If I told iTunes to start playing after Front Row started then I would have my audio playing while I was navigating through Front Row. If I then chose a song in Front Row I would get two audio streams playing. This is my reasoning for saying that Front Row has its own playback abilities.

So, since iTunes is not used then you won't be given the "Currently Playing" selection you are looking for. My suggestion is to hard-code the Front Row keystrokes in a script. You could make multiple scripts - One for each of your most common play lists. They will likely break if you add another playlist in iTunes.

-numero
     
ncmason
Guest
Status:
Reply With Quote
Nov 17, 2007, 09:28 PM
 
I really appreciate you helping me out with this. I may need to get some more info, because I am unaware on how to change Front Row's keystrokes to make it work like I want.

Thanks,
Mason
     
Junior Member
Join Date: Mar 2000
Location: Salem, OR, USA
Status: Offline
Reply With Quote
Nov 17, 2007, 10:38 PM
 
Here's what I would do:

1) Do it once by hand with Front Row. Write down every key stroke you make to do what you want. For example: from the main menu you push down arrow twice to get to "Music". For this step you should assume that the menu selection is on the top most item. Count the position from the top for the item you want to select. Press return and then count down to the next item you want.

2) Now make a script that does these steps. You already have the part about starting up Front Row and moving down and pushing "enter". Just put a bunch of the "key code 126" (up arrow) key commands every time you go into a new menu. That will force the selection to be the top most item. It doesn't hurt to put in more than you need. The selection won't wrap around to the bottom and it won't cause an error.

Like I said before, you will have to make a script for each playlist (or item) that you want to play since each script carries out the navigation to only one specific item. Also, if you add a playlist in iTunes then you take the risk of Playlist1 being in the 4th position instead of the 3rd so your "Play Playlist1" script will play the wrong item.

Let me know if you need more help.

-numero
     
ncmason
Guest
Status:
Reply With Quote
Nov 18, 2007, 08:58 AM
 
What is the code that will do the same as pressing the return key? If I can get the "return key" code after it reaches the "Songs" section, all I need it to do is then go to "Shuffle Songs". I'm just going to leave out the iTunes part, because it clearly doesn't make sense to have it running in the background.

Thanks,
Mason
     
Junior Member
Join Date: Mar 2000
Location: Salem, OR, USA
Status: Offline
Reply With Quote
Nov 18, 2007, 02:48 PM
 
I believe you had it in your original script. "key code 36".

Let me know if this isn't what you are asking for.

-numero
     
ncmason
Guest
Status:
Reply With Quote
Nov 18, 2007, 03:08 PM
 
I took out the iTunes part because it wasn't how I wanted it to work. The script below does everything right up until that step where I needed it to continue to the Shuffle Songs. I've tried adding "key code 36" at the end and it won't work. Maybe you know why this is?

tell application "System Events"
-- Command Esc. to start Front Row
key code 53 using command down
-- wait for Front Row to be ready for keyboard input
delay 4
end tell

tell application "System Events"
-- up arrow to guarantee top of menu
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
-- down arrow to get to Music
key code 125
key code 125
-- Press Return twice (Music -> currently playing)
key code 36
key code 36
end tell
     
Junior Member
Join Date: Mar 2000
Location: Salem, OR, USA
Status: Offline
Reply With Quote
Nov 18, 2007, 10:23 PM
 
You can take out the first "end tell" and also the second "tell application "System Events"". No need to get out and back in to System Events. That was just left over from my iTunes experiment.

Looks like you need to add a "delay 1" after every "key code 36" that you have. The commands come too fast for Front Row.

-numero
     
ncmason
Guest
Status:
Reply With Quote
Nov 19, 2007, 05:54 AM
 
Thanks. It worked!
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:34 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2