0

Java アプリケーションを別の方法で iTunes とやり取りするように変更しましたが、まだ AppleScript を使用していますが、私にとっては機能していますが、多くのユーザーに問題を引き起こしているようです。

10/20/13 12:37:44.553 PM iTunes[74256]: AppleEvents/sandbox: Returning 
errAEPrivilegeError/-10004 and denying dispatch of event rdwr/writ from process 
'Jaikoz'/0x0-0x413413, pid=19717, because it is not entitled to send an AppleEvent 
to this process.

しかし、なぜ彼がこのエラーを受け取るのか理解できません。私はそうではありません。

アップルスクリプト

tell application "iTunes"
    set thePath to (POSIX file "/tmp/jaikoz_itunes_model.txt")
    set fileref to open for access (thePath) with write permission
    set eof fileref to 0
    set mainLibrary to library playlist 1
    repeat with nexttrack in (get every track of mainLibrary)
        if (class of nexttrack is file track) then
            try
                set trackname to name of nexttrack
                set loc to location of nexttrack
                set locpath to POSIX path of loc
                set persistid to persistent ID of nexttrack
                set nextline to trackname & "::" & locpath & "::" & persistid
                write nextline & "\n" as "utf8" to fileref  starting at eof
            end try
        end if
    end repeat
end tell
return ""

更新 また、以前使用していた iTunes との対話方法が変更されたことにも気付きました。

osascript -a with Runtime.getRuntime().exec()

しかし今は

 ScriptEngineManager mgr = new ScriptEngineManager();
 ScriptEngine engine = mgr.getEngineByName("AppleScript");

それが問題でしょうか?

更新 2 Applescript エディターから実行すると同様のエラーが発生するため、これは純粋な Applescript の問題です。

25/10/2013 10:39:39.816 iTunes[3366]: AppleEvents/sandbox: Returning 
errAEPrivilegeError /-10004 and denying dispatch of event rdwr/writ
from process 'AppleScript Editor'/0x0-0x24d24d, pid=12717, because
it is not entitled to send an AppleEvent to this process.

問題は、iTunes にアクセスできないことではなく、iTunes がファイルに書き込む (またはファイルを開く/閉じる) たびに不平を言う - なぜでしょうか?

4

2 に答える 2

0

あなたの違いは次のようでした:

> set thePath to (POSIX file "/tmp/jaikoz_itunes_model.txt")
> set fileref to open for access (thePath) with write permission
> set eof fileref to 0
2,4d4
<     set thePath to (POSIX file "/tmp/jaikoz_itunes_model.txt")
<     set fileref to open for access (thePath) with write permission
<     set eof fileref to 0
14c14
<                 write nextline & "\n" as "utf8" to fileref  starting at eof
---
>                 tell current application to write nextline & "\n" as «class utf8» to fileref
18a19
> close access file ref

つまり、「現在のアプリケーションに指示」して何かを実行します。

于 2015-02-04T14:20:25.163 に答える