Managing UI elements that are not applescript aware

Hello all.

I have a slightly bizarre request. I’m working on something that has to intercept what the user is doing at the end of using Migration assistant. I’d like to regain control at the end of the process before they click “Log Out”

Obviously, Migration assistant doesn’t have a dictionary, so I’ve grabbed information using “Accessibility Inspector” about the window

Basically, I want a small script that does something when it detects that there is a button on the Migration Assistant window that says “Log Out”

An example of the Migration assistant screen is here:

Despite migration assistant killing all applications, I’m running mine as an agent, so running my app side by side with migration assistant isn’t an issue. I can even kill the UI of the app to ensure that there is only one window on the screen if need be

Ideas? I’ve no idea where to start in detecting the window, and the contents / buttons of the window

Got there:

tell application "System Events"
	tell process "Migration Assistant"
		-- set bob to title of button 3 of window 1
		set bob to title of window 1
		set fred to title of button 5 of window 1
	end tell
end tell


tell application “System Events”
get title of window 1 of process “Migration Assistant”
→ “Migration Assistant”
get title of button 5 of window 1 of process “Migration Assistant”
→ “Log Out”
end tell

The current Hierachy is:

– AXWindow
-------AX Children
----------- 0
----------- 1, etc
----------- 5

Accessibility Inspector really is useful!