Re: What is "system events" ?


Jean-Christophe Helary <jean.christophe.helary@...>
 

Thank you Phil.

On Oct 21, 2017, at 0:50, 2551phil <2551phil@...> wrote:

As to the question, System Events is an app, like any other app (sort of). It lives here:

/System/Library/CoreServices/System Events.app

The thing that makes it different is that it doesn’t have a GUI, and it’s whole purpose is to be accessed through Applescript for scripting (as it’s name implies) system functions such as inspecting running processes, sleeping, restarting and shutting down the computer. It can do quite a few other things, too, which you can explore through its Dictionary.

In one of the references that Bill mentioned (Matt Neuburg's TidBits article), there is a very enlightening explanation:


Blessed (System) Events -- At some point, someone at Apple put two and two together, as follows. "On the one hand, we've got the Accessibility API, which lets any program access the interface elements of any other program. On the other hand, we've got AppleScript, which lets any user write a script to give commands to any scriptable program. So what would happen if we put them together? Any user would be able to write a script to give commands to a scriptable program which would use the Accessibility API to access the interface elements of any program." To see the significance of this, just take out the middle terms, and what have you got? Any user can write a script that can access the interface elements of any program. Any user can script an unscriptable program, using AppleScript! You wouldn't need any special macro program, because AppleScript itself, which is already on your computer, would become a macro language.

Of course, for this to work, there has to be that "middle term" - the go-between, the application that receives AppleScript commands and talks to the Accessibility API. That application is called System Events. It's on your computer right now, in /System/Library/Core Services.

But here, he mentions only the accessibility API, which gives "GUI scripting", right?

What other practical use cases are there for System Events scripting? Would you have a simple example?

And thank you for the book reference. I'll be putting it either on my BD list or on my Xmas list :)

Jean-Christophe 

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