9

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?

12

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
  • That's what I want. Thanks. By the way, where can I find the documentations of the actions? – Yuxiao Zeng 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
  • 1
    AXRaise is not permitted in OS X 10.10 (Yosemite) and 10.11 (El-Capitan) unless you added the calling application (the one that executes the AppleScript) to the "Accessibility" section of the "Privacy" tab of the "Security & Privacy" System Preferences panel. This means that the first time you'll try to do it - you'll be presented with system UI that will suggest to take you to the preferences. I can't use it because of the detour in user-experience. Is there another way to raise the window without using AX (accessibility API's) ??? – Motti Shneor Oct 28 '15 at 11:28
-1

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. :)

  • 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. – Yuxiao Zeng Jul 30 '12 at 0:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .