Reputation: 45
I was thinking about what is the best way to use this statement for GUI Scripting:
tell application "System Events"
There is any difference with
tell application "System Events"
tell process "Finder"
-- do something with the GUI
end tell
end tell
and
tell application "Finder"
tell application "System Events"
-- do something with the GUI
end tell
end tell
Moreover It seems that "process" statement can access the GUI while application one can't.
Upvotes: 2
Views: 7009
Reputation: 2435
If you write
tell application "Finder"
tell application "System Events"
end tell
end tell
you need to keep the "Finder" tell structure open for as long as you need the "System Events" tell structure. This might mess up your code and it could cause problems if multiple apps have conflicting commands.
"System Events" rarely or never conflicts with anything and is needed relatively often. It makes sense to have a very long "System Events" tell structure but it doesn't make sense to have a very long "Finder" tell structure.
Whether you use process or application has nothing to do with it. Both can access GUI scripting, but you may need System Events to do this while controlling an app other than Finder.
Upvotes: 1
Reputation: 3429
It seems like you answered your own question. The first example works and is correct, the second example does not work and should not be used.
Upvotes: 1