4

I have a LiveCode app that, as part of a larger purpose, checks to see what the name of the "frontmost" application (i.e. the name in the menu bar). I am having LiveCode 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 app runs as a normal process, but when it is started by launchctl as a daemon, it doesn't work. I get the error

61:68: Syntax error: expected classname but found identifier (-2741).

Like I said, it only happens when the app is running as a daemon. Any ideas why?

btw: OS X 10.7.4

4

2 回答 2

0

确保脚本的所有者是 system 或 root 而不是您。您可以使用 chown 命令行实用程序来执行此操作(这包含在 Mac OS X 中)。10.7 及更高版本对权限相当挑剔。

于 2013-06-15T11:15:35.507 回答
0

不知道这是否仍然是一个问题,但如果它是一个相当微不足道的外部编写.. 基于此的东西:

for (NSRunningApplication *currApp in [[NSWorkspace sharedWorkspace] runningApplications]) {
        if ([currApp isActive]) {
             // return whatever property you want here
        }
    }
于 2013-03-07T09:05:00.810 回答