tell application - string vs. string?

2020-07-31 04:28发布

If I run:

tell application "Maps"
    set miniaturized of windows to false
end tell

...this works fine

Yet, when I run:

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

...I get:

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

I also tried:

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

...but I get the same error.

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

2条回答
Lonely孤独者°
2楼-- · 2020-07-31 04:52

This works for me using the latest version of Sierra

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

enter image description here

This also works for me

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

enter image description here

查看更多
叼着烟拽天下
3楼-- · 2020-07-31 04:59

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

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
查看更多
登录 后发表回答