我試圖在啓動plist內運行Applescript,但由於某種原因,它只是不工作。這可能是因爲它是我的電腦,但我認爲它可能有其他問題。如果有人可以看看這篇文章並發表評論,我會非常感激!啓動PLIST未運行
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.pf.Testing</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/osascript</string>
<string>-e</string>
<string>'tell application "Finder"' -e 'set didQuit to (path to home folder as string) & ".myApp"' -e 'if (exists file didQuit) then' -e 'tell application "TestApp"' -e 'activate' -e 'end tell' -e 'end if' -e 'end tell'</string>
</array>
<key>StartInterval</key>
<integer>20</integer>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
感謝您的幫助!
最新PLIST:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.pf.Testing</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/osascript</string>
<string>-e</string>
<string>'tell application "Finder"'</string>
<string>-e</string>
<string>'set didQuit to (path to home folder as string) & ".myApp"'</string>
<string>-e</string>
<string>'if (exists file didQuit) then'</string>
<string>-e</string>
<string>'tell application "TestApp"'</string>
<string>-e</string>
<string>'activate'</string>
<string>-e</string>
<string>'end tell'</string>
<string>-e</string>
<string>'end if'</string>
<string>-e</string>
<string>'end tell'</string>
</array>
<key>StandardErrorPath</key>
<string>/Users/pf/Desktop/Problem.log</string>
<key>StartInterval</key>
<integer>20</integer>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
嗨暱稱: 感謝您的回覆。不幸的是,即使在使用LimitLoadToSessionType代碼並仔細檢查路徑中是否存在文件後,它仍然無法運行。這真的很奇怪,尤其是因爲當我在終端中運行相同的代碼時,它工作得很好......任何想法? – PF1 2009-08-12 17:01:21
另一個想法:不要將applescript命令作爲參數傳遞,而是嘗試將它們放入單獨的腳本文件中,並將其路徑傳遞給osascript。 – 2009-08-13 12:07:05