AS to AS comms?

Posted on
Tue Jul 13, 2010 8:22 am
anode offline
Posts: 697
Joined: May 27, 2007
Location: NC

AS to AS comms?

Its a little off topic, but can an applescript talk to another? Do they need to be an 'app' over a script?

Posted on
Tue Jul 13, 2010 8:54 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: AS to AS comms?

Yes, you can, in much the same way that AppleScripts talk to Indigo - via apple events. You need to save your scripts as applications - at least a script that's the destination of a communication. So, a simple example:

Server Script saved as "SimpleServer.app":
Code: Select all
on showMessage(theMessage)
    display dialog theMessage
end showMessage


Client Script:
Code: Select all
tell application "SimpleServer"
    showMessage("Here's a test message")
end tell


2-way communication is much more tricky, since AppleScripts execute on the main thread. Each script would have to somehow process work but give periodic time to the main event loop to process incoming messages. I've never tried it before so I'm not sure how it would work. It might work by creating an AppleScript application in Xcode - that may give you the main event loop from which you can periodically run an AppleScript to do the processing and give you time to processes apple events from other processes. But, again, I've never tried it.

But, without more details of the problem domain it's just abstract thinking... ;)

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Jul 13, 2010 9:25 am
anode offline
Posts: 697
Joined: May 27, 2007
Location: NC

Re: AS to AS comms?

Thanks man!
Just need them hello world styles to point me in the right direction.

Page 1 of 1

Who is online

Users browsing this forum: Google [Bot] and 3 guests