MacOS – How to bring a window to frontmost without focusing it using Applescript in OS X 10.8

applescriptmacospython

I want to bring a window (QuickTime for example) to frontmost, without focusing it. I can do it in OS X 10.7 using the following code in Applescript.

tell application "System Events"
    set visible of process "QuickTime Player" to true
end tell

This is a Python equivalent.

from ScriptingBridge import *
process = SBApplication.applicationWithBundleIdentifier_('com.apple.systemevents').processes().objectWithName_('QuickTime Player')
process.setVisible_(True)

But it does not work after I upgraded to OS X 10.8. Is there any way to make it work?

Best Answer

If an application has open windows, this should raise them above windows from other applications, but keep them below ones from the current application.

tell application "System Events"
    perform action "AXRaise" of window 1 of process "QuickTime Player"
end tell