告诉应用程序 - 字符串与字符串

时间:2017-10-20 17:19:12

标签: applescript tell

如果我跑:

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

......我明白了:

地图出错:无法进行|小型化|将每个窗口转换为类型引用。

我也尝试过:

tell application (applicationName as string)
    ...
end tell

...但我得到了同样的错误。

我是Apple Script的新手,并不太了解两者之间的细微差别。

2 个答案:

答案 0 :(得分:1)

tell application的参数必须是文字字符串(常量),因为术语是在编译时计算的。

替代方案是using terms from application块,但参数也需要文字字符串

using terms from application "Maps"

end using terms from

答案 1 :(得分:0)

这适用于我使用最新版本的Sierra

set applicationName to "Maps"
tell application applicationName
    tell its windows
        set miniaturized to false
    end tell
end tell

enter image description here

这对我也有用

set applicationName to "Maps"
tell application applicationName's windows to set miniaturized to false

enter image description here

相关问题