2017-10-20 73 views
1

如果我运行:告诉应用程序 - 字符串与字符串?

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新手,不太了解两者之间的细微差别。

回答

1

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

另一种方法是using terms from application块,但参数需要一个字符串,也

using terms from application "Maps" 

end using terms from 
0

这使用最新版本的塞拉利昂的

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

+0

我也在运行Sierra(10.12.6),但这两个都不能在我的机器上运行。它们不会产生任何错误,但它们也不会恢复窗口。 – Jeff