Osascript - syntax error when starting from daemon (LiveCode application)

I have a LiveCode application that, as part of a larger goal, checks that the name of the β€œvery first” application (ie the name on the menu bar). I have a livecode to run this through the shell:

osascript -e 'tell application "System Events" to return name of every process whose frontmost is true' 

It works fine when the application runs as a normal process, but when it is launched using launchctl as a daemon, it does not work. I get an error

61:68: Syntax error: expected class name, but identifier found (-2741).

As I said, this only happens when the application is running as a daemon. Any ideas why?

btw: OS X 10.7.4

+4
source share
2 answers

I do not know if this is all a problem, but if it would be rather trivial to write. Something based on this:

 for (NSRunningApplication *currApp in [[NSWorkspace sharedWorkspace] runningApplications]) { if ([currApp isActive]) { // return whatever property you want here } } 
0
source

Make sure the owner of the script is system or root, not you. You can use the chown command line utility to do this (this is included on Mac OS X). 10.7 and later are pretty legible about permissions.

0
source

Source: https://habr.com/ru/post/1446333/


All Articles