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 > Help an AppleScript noob

Help an AppleScript noob
Thread Tools
0157988944
Professional Poster
Join Date: May 2007
Status: Offline
Reply With Quote
Aug 3, 2011, 07:58 PM
 
I'm using AppleScripts and RemoteBuddy to manage Plex, Hulu Desktop, EyeTV, and Boxee on my Mac TV setup. I'm by no means a pro at AppleScript so I'd hope I could get some help here.

The goal is for the script to close whichever app is open, launch Boxee, and tab over to "Apps" and hit enter so that basically the button that I assign this script to will take me straight to the app screen. This works great for everything except Hulu Desktop. That section of the script just won't send the keystrokes. I've tried putting in delays everywhere and even had it send the keystrokes over and over just to test and it just won't send them. Any help?

Code:
tell application "System Events" if exists process "EyeTV" then tell application "Boxee" to launch tell application "EyeTV" to close every window tell application "Boxee" to activate end if if exists process "Hulu Desktop" then tell application "Boxee" to launch tell application "Boxee" to activate tell application "System Events" to key code 124 tell application "System Events" to key code 124 tell application "System Events" to key code 36 tell application "System Events" to key code 124 delay 1 tell application "Hulu Desktop" to quit end if if exists process "Plex" then tell application "Plex" to quit tell application "Boxee" to launch tell application "Boxee" to activate delay 1 end if end tell tell application "Boxee" to activate tell application "System Events" to key code 124 tell application "System Events" to key code 124 tell application "System Events" to key code 36 tell application "System Events" to key code 124
     
BLAZE_MkIV
Professional Poster
Join Date: Feb 2000
Location: Nashua NH, USA
Status: Offline
Reply With Quote
Aug 3, 2011, 09:12 PM
 
I notice in the other two sections your closing the other application before manipulating boxee. Try quiting hulu and then put a while delay loop in till the process is gone before activating boxee.
     
0157988944  (op)
Professional Poster
Join Date: May 2007
Status: Offline
Reply With Quote
Aug 3, 2011, 09:14 PM
 
I've tried that as well, I'll try it with a really long delay just to see if Hulu is hanging.
     
Uncle Skeleton
Addicted to MacNN
Join Date: Nov 2002
Location: Rockville, MD
Status: Offline
Reply With Quote
Aug 4, 2011, 12:46 AM
 
It might be because you have a tell block within a tell block, both towards System Events. What happens if you take out the "tell app System Events to" part (of the inner blocks), leaving just "key code x"?
     
hayesk
Guest
Status:
Reply With Quote
Aug 4, 2011, 11:36 AM
 
Originally Posted by Uncle Skeleton View Post
It might be because you have a tell block within a tell block, both towards System Events. What happens if you take out the "tell app System Events to" part (of the inner blocks), leaving just "key code x"?
I think it's this.

Also, to simplify, you don't need to launch and activate. telling an app to activate will launch it too.
     
   
 
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
Top
Privacy Policy
All times are GMT -4. The time now is 03:56 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,