Support
All support resources for our products. Here you can find answers to frequently asked questions, discuss with other users, recover a lost license code or file a support request.
Forum closed
This forum was closed and turned into an archive effective April 21, 2018. It is no longer possible to create new topics or reply to existing topics.

Thanks everyone for all the great questions and contributions over the years.

Please use the Contact form to get in touch.

Remote Buddy Forum

Overview 

AuthorThread
User

28.02.2011 22:32:36
Script to exit FrontRow
View

This posting is older than 6 months and can contain outdated information.
Hi, I've been setting up a Harmony One to work with Plex/EyeTV/FrontRow along the lines of http://forums.plexapp.com/index.php/topic/13936-ultimate-mac-mini-theatre-setup/page__st__20

I've set up some shortcut buttons on the harmony to (through RemoteBuddy) execute applescript actions to switch between the apps above, first closing any open app.

I seem to get an occasional issue where RemoteBuddy hangs - I think perhaps due to FrontRow interaction. In this situation the remote becomes unresponsive and the mouse beachballs over the RB menu icon; I have to resolve by force-quitting RB. So I was wondering if there's a recommended way to close FrontRow from a script.

Currently I have (for closing all existing apps):

to closeAllApps(theAppName) 
-- theAppName is app we're about to switch to, to avoid closing & reopening 
set appNameList to {"iTunes", "Plex", "DVD Player"} -- change for the app you have installed

-- FrontRow is special because no applescript interface 
closeFrontRow(theAppName)

repeat with currentAppName in appNameList 
if ((currentAppName as text) is not equal to (theAppName as text)) then 
if application currentAppName is running then 
tell application currentAppName to quit 
end if 
end if 
end repeat 
-- EyeTV is special because we want to close video window but leave active to record programs 
closeEyeTV(theAppName)

end closeAllApps

to closeEyeTV(theAppName) 
-- EyeTV is special because we want it to continue running so that recordings are still made 
set myApp to "EyeTV" 
if ((myApp as text) is not equal to (theAppName as text)) then 
tell application "EyeTV" 
activate 
delay 2 
end tell

tell application "System Events" 
tell process "EyeTV" 
keystroke "w" using command down 
end tell 
end tell 
end if 
end closeEyeTV

to closeFrontRow(theAppName) 
set myApp to "Front Row" 
if ((myApp as text) is not equal to (theAppName as text)) then 
tell application "System Events" 
tell process "Front Row" 
keystroke home key 
end tell 
end tell 
end if 
end closeFrontRow

In summary, to close FrontRow, I send the homekey button as an input, directed hopefully to that process. Is there any better way? Have people experienced issues with RB hanging in conjunction with FrontRow before?

Thanks, 
stub5

These entries from the FAQ may be relevant to this topic:

Configuration
Hardware - Apple® Remote
Hardware - EyeTV Receiver
Hardware - Harmony® Smart Control
User

01.03.2011 04:07:54
Re: Script to exit FrontRow
View

This posting is older than 6 months and can contain outdated information.
 
I seem to get an occasional issue where RemoteBuddy hangs - I think perhaps due to FrontRow interaction. In this situation the remote becomes unresponsive and the mouse beachballs over the RB menu icon; I have to resolve by force-quitting RB. So I was wondering if there's a recommended way to close FrontRow from a script.

 
When Remote Buddy executes an AppleScript it (RB) remains unable to process anything else until the script has finished execution. So, if something goes wrong in a script, Remote Buddy will appear to hang until the script reaches its timeout value (the default is 120 seconds). Remote Buddy may also appear to hang with complex scripts where it remains unusable until the script completes. You can get around this by setting the timeout period to a lower value:

-- Begin Code -- 
tell application "My App" 
with timeout of 20 seconds 
--do something 
end timeout 
end tell 
-- End Code --

or by handing execution to the shell:

-- Begin Code -- 
do shell script "osascript the/path/to/your/script" 
-- End Code --

In the above example all you're doing is telling the UNIX part of OS X to run a script, so, the only part Remote Buddy cares about is "do shell script". Once that's executed—which, as a rule, should be instantaneous—Remote Buddy will be responsive, no matter how long your timeout or the complexity of your script.

Currently I have (for closing all existing apps):

to closeAllApps(theAppName) 
-- snip -- 
end closeEyeTV

 
You're off to a good start but, if I may offer some help here, your code can be much more efficient. It may seem like there's no point to saving half or one-tenth of a second when everything runs so quickly anyway, but these times add up, not to mention that the more text you've written, the longer it takes *you* to read and/or follow the logic. You'd be amazed at how much troubleshooting time one can save if short, efficient code is used from the start. And, as a general rule, GUI scripting is the absolute *last* method you should use.

EyeTV doesn't need to be "special"; there is a background process (EyeTV Helper) that controls your scheduled recordings and will launch the main app if necessary. That being said, I like to leave EyeTV running on my HTPC. All of your EyeTV code can be replaced with:

-- Begin Code -- 
tell application "EyeTV" to close every window 
-- End Code --

Your Front Row code can be simplified to:

-- Begin Code -- 
try 
do shell script "killall 'Front Row'" 
end try 
-- End Code --

And, overall, the entire block can be reduced as such:

-- Begin Code -- 
to closeAllApps(theAppName) 
set appNameList to {"iTunes", "Plex", "DVD Player"}

-- Kill Front Row 
if theAppName is not "Front Row" then 
try 
do shell script "killall 'Front Row'" 
end try 
end if

-- Close all EyeTV windows (or quit if desired) 
if theAppName is not "EyeTV" then 
tell application "EyeTV" to close every window 
end if

-- Code to quit iTunes, Plex, and DVD Player 
repeat with currentAppName in appNameList 
if currentAppName is not equal to theAppName then 
tell application currentAppName to quit 
end if 
end repeat 
end closeAllApps 
-- End Code --

Last edited: 01.03.2011 04:09:05

Last edited: 01.03.2011 04:12:41 

User

01.03.2011 09:12:18
Re: Script to exit FrontRow
View

This posting is older than 6 months and can contain outdated information.
Thanks for the help! I'll give your improvements a try.

stub5 

User

02.03.2011 23:22:02
Re: Re: Script to exit FrontRow
View

This posting is older than 6 months and can contain outdated information.
Thanks DaveD for your contributions here and in other threads!

You pretty much already said it all already, I just would like to add one more thing:

If you script "Front Row", you'll usually script the "Front Row" launcher, not Front Row itself - which most likely will leave your script, and thus (like DaveD already explained so well) Remote Buddy (which is executing your script) hanging.

Remote Buddy itself has no hang issues with Front Row. It only sends cursor/return/esc keystrokes to it.

Best regards, 
Felix Schwarz