Raise all windows of scriptable app

I’m working on a script and had a question. I want to raise all windows of some app (which has the focus and is scriptable but is otherwise unspecified) above all other apps. Right now I use GUI scripting, which does what I want, although I prefer to not use GUI scripting if that’s possible.

tell application "System Events"
	set activeApp to name of first process whose frontmost is true
	tell process activeApp
		click menu item "Bring All to Front" of menu "Window" of menu bar 1
	end tell
end tell

An alternative that also works but is a bit visually intrusive is:

tell application "System Events"
	set activeApp to name of first process whose frontmost is true
	tell process activeApp
		set windowCount to (count windows)
		repeat windowCount times
			tell window windowCount to perform action "AXRaise"
		end repeat
	end tell
end tell

Is there another alternative? I thought there might be an AXRaiseAll action or an ASObjC solution but couldn’t find anything. Thanks.

Give this a shot.

tell application "System Events"
	set activeApp to name of first process whose frontmost is true
	try
		perform action "AXRaise" of windows of process activeApp
	end try
end tell

OR

try
	tell application "System Events" to perform action "AXRaise" of windows of ¬
		process (get name of first process whose frontmost is true)
end try

Thanks wch1zpink–that works well. It’s surprising that the command reports an error (without the try statement) but still raises all of the app’s windows.