Reposition a Keyboard Maestro palette

palettes

#1

Move a Keyboard Maestro palette.zip (6.6 KB)

Custom Keyboard Maestro Plug-in

NAME

  • Move a named Keyboard Maestro palette

VERSION

  • 0.2
    • Updated to bring the moved palette to the front, so that it acts as the anchor if the move is followed by its companion plugin Tile all open KM palettes

SYNOPSIS

  • Changes the X and or Y position of the named palette
  • (X, Y) values are (across, down) in pixels

REQUIREMENTS

  • Yosemite
    • The core script movePalette.sh is mainly written in Javascript for Applications

OPTIONS

  • Name of palette
    • The global palette can be referred to as Global or Keyboard Maestro
    • Group and other palettes should be specifed exactly as spelled (case-sensitive) in their title bars
  • New X position:
    • Integer: pixels across (left edge of palette)
    • (or left blank to change only vertical position)
  • New Y position
    • Integer: pixels down (top edge of palette)
    • (or left blank to change only horizontal position)

INSTALLATION

  • Drag the .zip file onto the Keyboard Maestro icon in the OS X toolbar.
  • (if updating a previous version of the action, first manually remove the previous copy from the custom actions folder)
    • ~/Library/Application Support/Keyboard Maestro/Keyboard Maestro Actions

CONTACT


osascript -l JavaScript <<JXA_END 2>/dev/null
(function (strPaletteName, X, Y) {
	var dctReturn = {};
	if (!strPaletteName) {
		dctReturn.message = "Palette name not specified";
	} else {
		if (strPaletteName.toLowerCase() === 'global') strPaletteName =
			'Keyboard Maestro';
		var appSE = Application('System Events'),
			lstProc = appSE.applicationProcesses.where({
				name: 'Keyboard Maestro Engine'
			}),
			procKMEngine = lstProc.length ? lstProc[0] : null,
			oWin = procKMEngine.windows.byName(strPaletteName),
			lstXY, lstDXY;

		try {
			lstXY = oWin.position();
			oWin.position = [X || lstXY[0], Y || lstXY[1]];
			appSE.perform(oWin.actions['AXRaise']);
			
			lstDXY = oWin.position();
			dctReturn.message = (strPaletteName === 'Keyboard Maestro' ?
					'Global' : strPaletteName) +
				' palette moved to ' + lstDXY;
			dctReturn.x = lstDXY[0];
			dctReturn.y = lstDXY[1];
		} catch (e) {
			dctReturn.message = 'Palette not open, or not found as spelled: ' +
				strPaletteName;
		}
	}
	return JSON.stringify(dctReturn, null, 2);
})(
	"$KMPARAM_Palette_name",
	"$KMPARAM_New_X_position",
	"$KMPARAM_New_Y_position"
)
JXA_END

Position of Global Macro Palette
Controlling position of Global or Group Palette
#2

Awesome, thanks. Can’t wait to try it out. Mind if I share it on my http://macautomationtips.com blogsite?


#3

Of course – feel free

UPDATE

See also:


Get the current position of a Keyboard Maestro palette
#4

I’ve just updated this action (in the first post of this thread) See the installation notes for the details of how to install a new version.

( Essentially, it now brings the moved window to the foreground, which enables it to act as the anchor palette for a related tiling action )


Tile all open KM palettes horizontally or vertically
#5

@ComplexPoint, any chance you could update this plugin again to make it work with KM8.2.4 and Mojave? I drag the .zip file onto the KM menu icon and nothing happens. Thanks


#6

It seems to be working here – I attach a fresh zip:

Move a Keyboard Maestro palette.zip (6.6 KB)

At what point does it seem to be failing ?

Once you have installed it by dropping it on the KM icon, it should show up in the 3rd party plugins folder of the action-adding dialog:

33

and become available for inclusion in your macros.


#7

Thanks. I see it now. I didn’t know where it was suppose to go, and I couldn’t tell if it was installed. All is good now. It looks like it is exactly what I need. I will give it a test run. Thanks for creating it.


#8

Got it working. Thank you, thank you, thank you. It does exactly what I need.