Re: What is "system events" ?


2551phil
 

On 20 Oct 2017, at 23:10, Jean-Christophe Helary <jean.christophe.helary@gmail.com> wrote:
Bill mentioned (Matt Neuburg's TidBits article)…And thank you for the book reference. I'll be putting it either on my BD list or on my Xmas list :)nn
Same author.

What other practical use cases are there for System Events scripting?
Again, I can only refer you to the Dictionary and reiterate that, in this regard, it’s like any other app. What practical use is there for scripting the Finder, or Numbers? Doesn’t it depend on what they expose in their Dictionaries? Same is true of System Events.

When you look at the Dictionary, you’ll see a lot of overlap with the Finder, but if given the choice between the two, I’d go with System Events. However, (especially now we have the ASObjC bridge), I’d almost always try to find another way for just about anything if possible cos neither are that quick or that reliable.

Would you have a simple example?
Probably the thing I, personally, use System Events the most for is in Script Debugger to see what properties, objects and classes of other apps I can manipulate. Thus

tell application "System Events"
#~-- your code goes here...~#
end tell

is a common go-to I use, where I never fill in the ‘your code goes here’ part or even compile the script. I just leave the cursor on the first line within “System Events” and use SD’s live inspector to browse the goodies.

I think there’s a video on the latenightsw site showing how to do this if you’re not familiar with what I’m talking about.


Best


Phil
@sqwarq

Join applescript@apple-dev.groups.io to automatically receive all group messages.