1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Applescript: activate app of machine

Discussion in 'Mac Programming' started by SilentPanda, Jan 9, 2007.

  1. Moderator emeritus

    SilentPanda

    #1
    Edit: I figured it out. Apparently I don't need the drive/directory qualifiers. Just iTunes was sufficient. But I'll leave the rest here for the "internet archival process". :)

    So I'm just getting into Applescript and it's coming along well but I'm poking around on the way. I'm trying to get iTunes to activate on my laptop (I'm on my desktop). I have Remote Apple Events on but it won't activate it. The program is running and behind a Safari window. Here is the code:

    Code:
    activate application "Macintosh HD:Applications:iTunes" of machine "eppc://192.168.0.186"
    I've tried using Macintosh \\HD just in case the space goofed it up, then I tried renaming the HD to MobileHD and updated the Applescript accordingly and still no dice. I keep getting this error (pictured below).

    Certainly not urgent as I'm just poking around but more curious what I'm doing wrong here. The book I'm going through is "AppleScript Handbook" which was written for 10.3. Should still be okay but I know language things change from version to version too.
     
  2. macrumors member

    #2
    It's been awhile but try this...

    Code:
    set computers_IP to "xxx.xx.x.x" -- your target computers local IP address
    set the_computer to machine "eppc://" & computers_IP
    tell application "iTunes" of the_computer
    	using terms from application "iTunes"
    		activate
    	end using terms from
    end tell
    If that doesn't work try this...

    Code:
    set computers_IP to "xxx.xx.x.x" -- your target computers local IP address
    set the_computer to machine "eppc://" & computers_IP
    tell application "System Events" of the_computer
    	using terms from application "System Events"
    		tell application "iTunes"
               activate
               end
    	end using terms from
    end tell
     
  3. macrumors member

    simplebeep

    #3
    Hmmm...

    I tried this trick on some computers in a lab. All of them are using OS 10.2.8. When I run this code:
    Code:
    set theReply to display dialog "Computer number:" default answer ""
    set thePrevious to the text returned of the result
    set thePrevious to "eppc://1541-" & thePrevious & ".local"
    set m to machine (thePrevious)
    
    tell application "System Events" of m
    	using terms from application "System Events"
    		display dialog "Hello World"
    	end using terms from
    end tell
    and enter the machine address, I get a message saying "System Events got an Error: Could not establish connection to host."

    Both computers have remote apple events turned on and have been successfully networked in the past. What is wrong?

     

Share This Page