告诉应用程序-字符串还是字符串? [英] tell application - string vs. string?

查看:98
本文介绍了告诉应用程序-字符串还是字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我跑步:

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

...我得到:

地图出现错误:无法将其|小型化|每个窗口的类型引用.

Maps got an error: Can’t make |miniaturized| of every window into type reference.

我也尝试过:

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

...但是我遇到了同样的错误.

...but I get the same error.

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

I'm new to Apple Script and not quite understanding the nuances between the two.

推荐答案

tell application的参数必须是文字字符串(常量),因为该术语是在编译时评估的.

The argument of tell application is required be a literal string (a constant) because the terminology is evaluated at compile time.

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

The alternative is an using terms from application block but the argument requires a literal string, too

using terms from application "Maps"

end using terms from

这篇关于告诉应用程序-字符串还是字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆