macOS, is my app active?

Klaus major-k klaus at
Sat Nov 23 09:11:41 EST 2019

Hi Trevor,

> Am 23.11.2019 um 15:06 schrieb Trevor DeVore via use-livecode <use-livecode at>:
> On Sat, Nov 23, 2019 at 6:24 AM Klaus major-k via use-livecode <
> use-livecode at> wrote:
>> Hi friends,
>> can we check if our standalone is currently active, means in
>> the "foreground" or if it is not active? Know what I mean?
>> If yes, how can we do that? LC? AppleScript?
>> I want to alert the user if the app is active, but not if the app
>> is not active.
> Apple provides API calls to do this and wrapping Objective-C APIs is pretty
> straightforward. The APIs you are interested in:
> ...
> Regarding step 6 - If you don't want to store your extension externally to
> your application you can also use the "+" button in the EB to install the
> extension in your LC environment. Now the extension will load whenever you
> launch LC and you can select "NSWorkspace" in the Standalone Builder
> Inclusions tab so that the extension is bundled with your executable.
> -- 
> Trevor DeVore

wow, lots of infos, thank you very much, but maybe a little overkill for me.

It would suffice for me to get this little snippet to work:
tell application "System Events"
	set activeApp to name of first application process whose frontmost is true
	return activeApp
end tell
Works fine in the AppleScript Editor, but I get "execution error" when DOing this in LC!?
Any hints appreciated!

Thanks a lot!


Klaus Major
klaus at

More information about the use-livecode mailing list