Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos AppleScript';s tell语句无条件打开firefox,忽略封闭的if块_Macos_Applescript - Fatal编程技术网

Macos AppleScript';s tell语句无条件打开firefox,忽略封闭的if块

Macos AppleScript';s tell语句无条件打开firefox,忽略封闭的if块,macos,applescript,Macos,Applescript,我遇到以下问题 剧本 osascript <<EOF if false is true tell application "Firefox" to activate end if EOF osascriptFirefox不支持AppleScript,因为它不包含AppleScript字典文件,例如在其应用程序包的资源文件夹中不包含Firefox.sdef,并且只支持标准套件的一些基本命令 要防止使用OP中显示的代码打开Firefox,您需要标记(设置为变量)其

我遇到以下问题

剧本

osascript <<EOF
if false  is true
tell application "Firefox" to activate
end if
EOF

osascriptFirefox不支持AppleScript,因为它不包含AppleScript字典文件,例如在其应用程序包的资源文件夹中不包含Firefox.sdef,并且只支持标准套件的一些基本命令

要防止使用OP中显示的代码打开Firefox,您需要标记(设置为变量)其
名称,如下例所示:

osascript
osascript <<EOF
if false is true
set appName to "Firefox"
tell application appName to activate
end if
EOF
osascript <<EOF
if false is true
set |Firefox| to "Firefox"
tell application |Firefox| to activate
end if
EOF