Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ScottishCaptain

macrumors 6502a
Original poster
Oct 4, 2008
871
474
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?

-SC
 

benwiggy

macrumors 68020
Jun 15, 2012
2,367
178
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.
 

ScottishCaptain

macrumors 6502a
Original poster
Oct 4, 2008
871
474
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.

-SC
 

ScottishCaptain

macrumors 6502a
Original poster
Oct 4, 2008
871
474
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).

-SC
 

benwiggy

macrumors 68020
Jun 15, 2012
2,367
178
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.
 

ScottishCaptain

macrumors 6502a
Original poster
Oct 4, 2008
871
474
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.

-SC
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.