AppleScript: GUI scripting

Joined
Aug 10, 2016
Messages
28
Reaction score
0
Points
1
I want to script Emacs, which is unscriptable in OSX, but my understanding is that most unscriptable programs can have some support through "System Events", otherwise known as GUI scripting.

I want to start with raising windows with a particular name. I used the following script successfully.

tell tell application "Emacs"
activate
end tell
tell application "System Events"
tell application process "Emacs"
tell window 1
keystroke "foo"
end tell
end tell
end tell


In this case, Emacs had two frames, and this typed "foo" into the first frame. So that's good. But what I really want to do is raise a particular Emacs window, determined by its name. I tried the following:

tell application "Emacs"
activate
end tell
tell application "System Events"
tell application process "Emacs"
get name of window 1
end tell
end tell

This gave an error "Can't get window 1 of process Emacs, invalid index". So I am confused appartenly it works to "tell" window 1 something, but trying to "get" something returns the result that it doesn't exist?

Ultimately what I want to do is raise a particular window. Can anyone help?

Note that I am trying to avoid paid macro programming software, as I just don't see a need for it. I am a programmer, and this stuff should be doable with AppleScript and Automator.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top