Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 7 down vote accepted

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
share|improve this answer
    
That's what I want. Thanks. By the way, where can I find the documentations of the actions? –  Pink Jul 31 '12 at 13:49
1  
Accessibility Roles and Attributes Reference: Actions. You can see what actions UI elements support with actions of or by using Accessibility Inspector. –  Lri Jul 31 '12 at 13:53

So, from what I gather from your post, you are trying to bring an application into view using Applescript? If so, the code for this in Mountain Lion is actually fairly simple! Here it is:

tell application "Quicktime Player"
activate
end tell

I hope this works! If it's not what you wanted, let me know and I'll update it for you. :)

share|improve this answer
2  
Well, activate will focus Quicktime, so it is not what I want. I mean, if you open Applescript application, type your code and run it, window focus will be moved to Quicktime. As a result, you cannot type any code before you click the Applescript window for example. –  Pink Jul 30 '12 at 0:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.