Page 1 of 1

Transferring variables between AppleScript and LiveCode

Posted: Wed Jun 10, 2026 8:13 am
by sipsuper
Hello, everyone.

may anyone explain how I may pass a variable from Applescript to Livecode? The execution context is Applescript (e., I am not running Applescript from within Livecode).

The example I'm attempting to get working is providing a value from a service menu applescript.

I believe this could be accomplished by sending an Appleevent and then interrogating the value of the Applescript (event handler) in Livecode, but I haven't found an example.

Thank you in advance for your ideas.

Re: Transferring variables between AppleScript and LiveCode

Posted: Thu Jun 11, 2026 9:59 am
by bn
hi sipsuper,

Long ago I did some inter application communication using AppleScript. LC's AppleScript support is limited. Digging in my old AS scripts I adapted one to what I think is similar to what you have in mind.
The AppleScript script: (use apple script's ScriptEditor to trigger the AS script from outside of LC)

Code: Select all

set tParameter to the current date
set tParameter to "  your value  " & the seconds of tParameter --  a test parameter/ would be your parameter
set tStackName to "ReceiverStack" -- your stackname here
set tCommand to "foo" -- your receiver handler here at the card level or up

-- construct an AppleScript script for Livecode here
set myScript to "send \"" & tCommand & "\" && quote & \"" & tParameter & "\" & quote to current card of stack \"" & tStackName & "\""
tell application "LiveCode 10.0.4" to do script myScript -- this executes the 
set x to the result
Create a stack "Receiver" with 1 field "fRes" with a script at the card level:

Code: Select all

on foo pParameter
   beep
   put pParameter into field "fRes"
end foo
Kind regards
Bernd

Re: Transferring variables between AppleScript and LiveCode

Posted: Thu Jun 11, 2026 10:25 am
by stam
Hi Bernd,

I'm not sure that's the what the OP is asking but may be wrong.
Looks like they're using AppleScript independent of LiveCode but want to send an AppleScript event to LiveCode with a value to be processed there.

This strikes me as the wrong way round and my understanding is about the same as yours. But I'm not sure how an AppleScript can pass an event to LiveCode when the script is not running within LiveCode, which is my understanding of the OP (happy to be corrected...)

Re: Transferring variables between AppleScript and LiveCode

Posted: Thu Jun 11, 2026 10:49 am
by bn
Hi Stam,

I am not sure what the OP has in mind either.
I figured the OP has a Livecode thing running that uses the parameter from "service menu applescript" outside of LC to process it in a Livecode stack.
That is what the example shows. The AScript would be integrated in the external process.
I am quite curious to know his use case is.
Kind reagards
Bernd

Re: Transferring variables between AppleScript and LiveCode

Posted: Thu Jun 11, 2026 3:23 pm
by dunbarx
Bernd, Stam.

Is it possible the OP is talking about the form "do as AppleScript", and wants some data to return to LC?

Craig

Re: Transferring variables between AppleScript and LiveCode

Posted: Thu Jun 11, 2026 8:36 pm
by bn
Is it possible the OP is talking about the form "do as AppleScript", and wants some data to return to LC?
I think right now it is best to let the original poster explain in more detail what he wants.

KInd regards
Bernd

Re: Transferring variables between AppleScript and LiveCode

Posted: Sun Jun 14, 2026 2:33 pm
by stam
dunbarx wrote: Thu Jun 11, 2026 3:23 pm Is it possible the OP is talking about the form "do as AppleScript", and wants some data to return to LC?

Always possible, and as Bernd says, best to wait for the OP to clarify, but according to the initial post (emphasis mine):
The execution context is Applescript (e., I am not running Applescript from within Livecode).

Re: Transferring variables between AppleScript and LiveCode

Posted: Sun Jun 14, 2026 3:41 pm
by dunbarx
Stam.

Right you are.

But assuming LC is running on his machine, and whatever the source of the appleScript, how would any such source pop itself into LC? Where would it land?

Craig

Re: Transferring variables between AppleScript and LiveCode

Posted: Sun Jun 14, 2026 4:47 pm
by richmond62
That might be a 'clever' bot: considering it is a single post