macOS, is my app active?

Bob Sneidar bobsneidar at iotecdigital.com
Mon Nov 25 11:46:35 EST 2019


on mouseUp
   put "tell application " & quote & "System Events" & quote & cr after tApplescript
   put "set activeApp to name of first application process whose frontmost is true" & cr after tApplescript
   put "return activeApp" & cr after tApplescript
   put "end tell" & cr after tApplescript
   do tAppleScript as appleScript
   put the result
end mouseUp

works for me

Bob S


> On Nov 23, 2019, at 06:11 , Klaus major-k via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> Hi Trevor,
> 
>> Am 23.11.2019 um 15:06 schrieb Trevor DeVore via use-livecode <use-livecode at lists.runrev.com>:
>> 
>> On Sat, Nov 23, 2019 at 6:24 AM Klaus major-k via use-livecode <
>> use-livecode at lists.runrev.com> 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!
> 
> 
> Best
> 
> Klaus
> --
> Klaus Major
> https://www.major-k.de
> klaus at major-k.de
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list