1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

How to tell if Launchpad is "open"?

Discussion in 'OS X Mountain Lion (10.8)' started by ScottishCaptain, Apr 10, 2013.

  1. macrumors 6502a

    Greetings to all.

    Quick question... How can one tell if Launchpad is open and in the foreground?

    Is there some way of doing this through Applescript, or otherwise checking out which process is open in the background?

    Near as I can tell, Launchpad is a part of Dock, and Launchpad.app exists solely to poke the Dock and tell it to display Launchpad. Except, the Dock doesn't actually come to the foreground like a normal window or anything when Launchpad is open, so you can't tell if Launchpad is open that way either. And since the Dock is always running in the background, it's impossible to use that process to determine if Launchpad is open as well.

    Is there some way of determining if Launchpad is open via Applescript, or some other method?

  2. macrumors 68020

    What is your ultimate goal? Are you trying to launch/run an AppleScript when LaunchPad is running? What will it do?

    There may be another method of achieving your high goal than the way you're suggesting.

    The Dock is a pretty non-standard and low-level process.
  3. macrumors 6502a

    In a nutshell, I'm using ControllerMate to customize some buttons on my mouse, and gearing them towards use with Launchpad.

    In order to do the things I want to do with my buttons, I need the ability of knowing whether or not Launchpad is actually open. ControllerMate's built-in blocks that tell you if an app is in the foreground or not don't with with Launchpad because, as I said, Launchpad is part of the Dock and the Dock doesn't "come into the foreground" when you activate Launchpad.

    ControllerMate does, however have the ability to run an arbitrary Applescript script. So I was wondering if there was some way to detect whether or not Launchpad is open through Applescript, but there doesn't appear to be. Launchpad spawns no processes (that aren't already open), and gives no indication of being in the foreground when open. Which kinda sucks.

  4. macrumors 68020

    And what are the things you want to do with your buttons? LaunchPad has fairly limited capabilities -- you can flick between pages and type in names. AFAIK, that's about it.
  5. macrumors 6502a

    Yeah, trust me, I know.

    I simply wanted to have ControllerMate swap the functionality of that button depending on if Launchpad is open or not. If it isn't, then ControllerMate would automatically map that button to opening Launchpad.app. If Launchpad was already open, then ControllerMate would map that button to the escape key on the keyboard.

    The reason for this was so that I could just mash the same mouse button to close Launchpad folders without pawing around to hit the empty space or physically pressing the escape key on my actual BT keyboard.

    It would be possible if I had some way of telling if Launchpad was being displayed or not. Unfortunately it doesn't seem like this is possible, unless I've missed something somewhere (apps in the background while Launchpad is open don't lose focus, from Applescript's view they're still in the foreground- and since Launchpad doesn't spawn a process of its own, you can't check PIDs or anything).

  6. macrumors 68020

    You can assign a keyboard shortcut to Launchpad in System Prefs > Keyboard > Keyboard Shortcuts. Select Launchpad & Dock on the left, then select LaunchPad, hit Enter and press your keystroke. Say F2.

    F2 will now launch and quit LaunchPad. So you can assign that shortcut to your mouse button.

    EDIT: Oh, that's not quite what you want. I'll have another think.
  7. macrumors 6502a

    Yeah, no, I've already figured that out.

    I just need some way of determining if Launchpad is active and in the foreground or not- that's all. The only thing that occurred to me was reading screen pixels, but that's kinda ugly.


Share This Page