告诉应用程序 - 字符串与字符串?
tell application - string vs. string?
如果我运行:
tell application "Maps"
set miniaturized of windows to false
end tell
...这很好用
然而,当我 运行:
set applicationName to "Maps"
tell application applicationName
set miniaturized of windows to false
end tell
...我得到:
地图出现错误:无法|小型化|每个 window 类型引用。
我也试过:
tell application (applicationName as string)
...
end tell
...但我得到了同样的错误。
我是 Apple Script 的新手,不太了解两者之间的细微差别。
tell application
的参数必须是文字字符串(常量),因为术语是在编译时求值的。
替代方案是 using terms from application
块,但参数也需要文字字符串
using terms from application "Maps"
end using terms from
这对我使用最新版本的 Sierra 很有效
set applicationName to "Maps"
tell application applicationName
tell its windows
set miniaturized to false
end tell
end tell
这也适用于我
set applicationName to "Maps"
tell application applicationName's windows to set miniaturized to false
如果我运行:
tell application "Maps"
set miniaturized of windows to false
end tell
...这很好用
然而,当我 运行:
set applicationName to "Maps"
tell application applicationName
set miniaturized of windows to false
end tell
...我得到:
地图出现错误:无法|小型化|每个 window 类型引用。
我也试过:
tell application (applicationName as string)
...
end tell
...但我得到了同样的错误。
我是 Apple Script 的新手,不太了解两者之间的细微差别。
tell application
的参数必须是文字字符串(常量),因为术语是在编译时求值的。
替代方案是 using terms from application
块,但参数也需要文字字符串
using terms from application "Maps"
end using terms from
这对我使用最新版本的 Sierra 很有效
set applicationName to "Maps"
tell application applicationName
tell its windows
set miniaturized to false
end tell
end tell
这也适用于我
set applicationName to "Maps"
tell application applicationName's windows to set miniaturized to false