Thursday, December 14, 2017

#1 2016-01-21 10:07:14 am

willpeters
Member
Registered: 2011-12-31
Posts: 3

connection to remote machine in ASOC projects

Hello everyone,
I am currently creating a new ASOC project in Xcode. I have created a few projects using Shane Stanley's excellent book as a resource. Kudos to Shane.

To my question, I am in the process of writing my first ASOC project which includes remote apple events to control Excel on a remote computer. Shane does have some information about controlling applications on the remote machine, but not to make the connection to the machine itself. I am curious if anyone can help with the syntax i need to use to make the connection.

Going back to the AppleScript Studio days, you could use a connection such as this, then control the application

Applescript:


set theRemoteMac to "eppc://username:password@ip_address"

tell application "Excel" of machine theRemoteMac
       using terms from application "Microsoft Excel"
--do stuff here
end using terms from
end tell

In ASOC projects it doesn't seem to work that way. If I use the "of machine" command (from the AppleScript Studio days), I receive a "Cannot find remote machine" error.

Using Shane's book as a guideline, i have my code currently written as follows...

Applescript:


set theRemoteMac to "eppc://username:password@ip_address"

set theApp to application ((theRemoteMac as text) & "/Microsoft Excel")
using terms from application "Microsoft Excel"
tell theApp
--DO STUFF HERE
end tell
end using terms from

but this code produces the following error...   Microsoft Excel got an error: Application isn’t running.

Any thoughts as to how I need to word my syntax to make the connection?

If there is any further information I can supply, please let me know.

Thanks everyone!

Offline

 

#2 2016-01-21 10:37:16 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11482
Website

Re: connection to remote machine in ASOC projects

Hi,

you cannot launch an application on a remote machine directly. You have to tell the Finder to do that.
Fortunately the processes list is also available in Finder


Applescript:

tell application "Finder" of machine theRemoteMac
   using terms from application "Finder"
       if "Microsoft Excel" is not in (get name of processes) then open application file id "com.microsoft.Excel"
   end using terms from
end tell

I'm not sure whether the name of the process and the bundle identifier are correct.


regards

Stefan

Offline

 

#3 2016-01-21 10:45:00 am

willpeters
Member
Registered: 2011-12-31
Posts: 3

Re: connection to remote machine in ASOC projects

Hi StefanK,
Thank you for the quick reply. Much appreciated. I will give this a try to see if it works in my Xcode project.

After I posted my original message, i realized where I went wrong in the syntax (it was in the call to the application itself). I made I minor change to my original code and I can make the remote connection as expected now...

Applescript:


set theRemoteMac to "eppc://username:password@ip_address"

set theApp to application ((theRemoteMac as text) & "/Microsoft Excel") -- ORIGINAL CODE
set theApp to application ((theRemoteMac as text) & "/Excel") -- NEW CODE - NOW WORKING
using terms from application "Microsoft Excel"
tell theApp
--DO STUFF HERE
end tell
end using terms from

the change is subtle, but after looking back at old ASStudio code, i found making this minor change works in ASOC as well.

Thanks again!

Offline

 

#4 2016-02-28 10:18:56 am

zoff
Member
Registered: 2012-10-18
Posts: 12

Re: connection to remote machine in ASOC projects

Hi willpeters- can you tell me which operating systems you are using, on the remote machine and the local machine?

My Apple Remote Events have been broken for some time. I'm running my script form El Capitan to a mac running Leopard  and I probably need a newer remote operating system with updated security.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)