Reputation: 1
I am get the following error when I try to set miniaturized of a window to false/true for an application whose name I supply as a variable.
set x to "Safari"
tell application x to set miniaturized of the front window to false
ERROR
miniaturized-safari.scpt:40:85: execution error: Safari got an error: Can’t make |miniaturized| of window 1 into type specifier. (-1700)
while I don't get any error when I try the following
tell application "Safari"
to set miniaturized of the front window to false
Upvotes: 0
Views: 612
Reputation: 1
The short version is that standard, universal terms will work via an indirect reference (tell application x), but application-specific terms won't.
This includes standard commands such as 'open', 'close', 'quit', 'activate', plus a few standard object types. All applications should respond to these.
In this case, although you might think that miniaturized is standard, it isn't universal. Not all applications support this property for their windows, so it depends entirely on the application and therefore needs a specific 'tell' or 'using terms from...' (so that the Script Editor can understand which dictionary terms are available).
Upvotes: 0
Reputation: 17811
As vadian correctly notes the AppleScript terminology is evaluated at compile time. So to make this work you have to specify at compile time what terms to use.
set x to "Safari"
tell application x
using terms from application "Safari"
set miniaturized of the front window to false
end using terms from
end tell
This will work as long as the specified app uses compatible terms for window miniaturized
as the one specified by the variable.
Upvotes: 0
Reputation: 507
I have found this solution that is working for me:
tell application (path to frontmost application as text)
reopen -- unminimizes the first minimized window or makes a new default window
end tell
Works for Finder as well. Anyway there are apps it is not working for (eg. Office).
Upvotes: 0
Reputation: 285270
AppleScript terminology is evaluated at compile time.
This is the reason why applications specified in tell
blocks must be constants.
Upvotes: 0