有没有人可以帮我调试我将变量传递给applescript的尝试,并测试当前是否正在运行另一个应用程序。
要使emacsclient
正常工作,Emacs GUI服务器需要运行 - 首先我要验证Emacs GUI正在运行[(server-start)
已经在我的init.el
文件中 - - 如果是这样,然后在继续启动emacsclient
之前立即进入前台(焦点) - 否则,启动Emacs GUI并等待服务器启动。然后,运行emacsclient
以打开指定的文件。从终端,我想输入:
osascript script-name variable-file-name
脚本错误:运行处理程序被多次指定,或者除了运行处理程序之外还有顶级命令。 (-2752)
on is_running(appName)
tell application "System Events" to (name of processes) contains appName
end is_running
set EmacsRunning to is_running("Emacs")
if EmacsRunning then
tell application "/Users/HOME/.0.data/.0.emacs/Emacs.app/Contents/MacOS/Emacs" to activate
else
tell application "/Users/HOME/.0.data/.0.emacs/Emacs.app/Contents/MacOS/Emacs" to activate
delay 1
end if
on run arg
do shell script "/Users/HOME/.0.data/.0.emacs/Emacs.app/Contents/MacOS/bin/emacsclient arg"
end run
答案 0 :(得分:1)
尝试:
on run argv
set argvApp to application (argv as text) --Coerce list to text
set appIsRunning to argvApp is running
if appIsRunning then
beep 1
--insert your code
else
beep 2
--insert your code
end if
(*
tell application "SystemUIServer"
activate
display dialog appIsRunning
end tell
*)
end run