如何让osascript不生成在运行时不会命中的applescript代码?

如何让osascript不生成在运行时不会命中的applescript代码?,applescript,Applescript,我们有一个脚本,可以使用Microsoft outlook或Apple mail应用程序发送电子邮件。它将从系统首选项(也可能是用户输入)动态加载默认电子邮件,并使用它来决定使用哪个邮件客户端 因此,代码如下所示: if (mailClientStr contains "outlook") tell application id "com.microsoft.outlook" -- <<< there will be error if there is no ou

我们有一个脚本,可以使用
Microsoft outlook
Apple mail
应用程序发送电子邮件。它将从系统首选项(也可能是用户输入)动态加载默认电子邮件,并使用它来决定使用哪个邮件客户端

因此,代码如下所示:

if (mailClientStr contains "outlook")
   tell application id "com.microsoft.outlook" 
   -- <<< there will be error if there is no outlook installed 
   -- <<< even else branch will be run.
      ...
   end tell
else
   tell application id "com.apple.mail"
      ...
   end tell
end if
if(mailClientStr包含“outlook”)
告诉应用程序id“com.microsoft.outlook”

--来自AppleScript语言指南:

Entering Script Information in Raw Format

You can enter double angle brackets, or chevrons («»), directly into a script by typing Option-Backslash and Shift-Option-Backslash. You might want to do this if you’re working on a script that needs to use terminology that isn’t available on your current machine—for example, if you’re working at home and don’t have the latest dictionary for a scriptable application you are developing, but you know the codes for a supported term.

You can also use AppleScript to display the underlying codes for a script, using the following steps:

    Create a script using standard terms compiled against an available application or scripting addition.

    Save the script as text and quit Script Editor.

    Remove the application or scripting addition from the computer.

    Open the script again and compile it.

    When AppleScript asks you to locate the application or scripting addition, cancel the dialog.

Script Editor can compile the script, but displays chevron format for any terms that rely on a missing dictionary