Macos applescript如果在“以后找不到应用程序,如何忽略浏览窗口”;告诉应用程序X启动";?
我有一个小的启动脚本,可以在系统启动时启动一些应用程序。最近,我删除了上个应用程序,每次它启动时,都会显示一个浏览窗口来查找丢失的应用程序。如果没有应用程序,有没有一种方法可以告诉它忽略它——直接跳过它 以下是我尝试过的:Macos applescript如果在“以后找不到应用程序,如何忽略浏览窗口”;告诉应用程序X启动";?,macos,applescript,Macos,Applescript,我有一个小的启动脚本,可以在系统启动时启动一些应用程序。最近,我删除了上个应用程序,每次它启动时,都会显示一个浏览窗口来查找丢失的应用程序。如果没有应用程序,有没有一种方法可以告诉它忽略它——直接跳过它 以下是我尝试过的: try tell application "junk2" to launch on error set myMessage to "Error launching " & appName end try 所以
try
tell application "junk2" to launch
on error
set myMessage to "Error launching " & appName
end try
所以,我只需要将myMessage设置为error message并继续。如何进行
谢谢您需要命令“使用应用程序中的术语”(谷歌搜索详细解释)。如果将applescript代码保存为应用程序,并且必须在具有该应用程序的计算机上创建它,则此操作将有效。这两件事将防止脚本需要在运行代码的计算机上编译,这将防止如我所解释的那样创建脚本时出现错误。因此,在这个脚本中,我们使用mdfind检查计算机上是否存在应用程序,如果存在,则启动应用程序
set appName to "TextWrangler.app" -- notice here I add .app to ensure the application itself is found with mdfind and not other types of documents
set appPath to paragraphs of (do shell script "mdfind " & quoted form of appName)
if appPath is {} then
return "The app does not reside on the system!"
else
-- notice here I did not use the variable
using terms from application "TextWrangler"
tell application "TextWrangler" to launch
end using terms from
end if
您需要使用命令“使用应用程序中的术语”(谷歌搜索以获得详细解释)。如果将applescript代码保存为应用程序,并且必须在具有该应用程序的计算机上创建它,则此操作将有效。这两件事将防止脚本需要在运行代码的计算机上编译,这将防止如我所解释的那样创建脚本时出现错误。因此,在这个脚本中,我们使用mdfind检查计算机上是否存在应用程序,如果存在,则启动应用程序
set appName to "TextWrangler.app" -- notice here I add .app to ensure the application itself is found with mdfind and not other types of documents
set appPath to paragraphs of (do shell script "mdfind " & quoted form of appName)
if appPath is {} then
return "The app does not reside on the system!"
else
-- notice here I did not use the variable
using terms from application "TextWrangler"
tell application "TextWrangler" to launch
end using terms from
end if