Here's a macro library to move windows with numeric keypad

Before Keyboard Maestro, I never used the numeric keypad. KM makes the numeric keypad useful as a set of extra, distinct keys. I leverage the physical layout of the keypad to help remember which key does what.

I used to move windows around the screen manually. I wasted time trying to position windows down to the pixel level, to reduce clutter and use as much screen as possible. This became more important to me when I upgraded to Yosemite, when Apple enhanced the Terminal app to draw a faint 1-pixel border around the edges of Terminal windows. That makes Terminal windows stand out when the background Terminal color matches the desktop color. But that border disappears if you sloppily position Terminal windows slightly off the edge of the screen. How annoying. How unaesthetic.

I bound KM macros to numeric keypad keys to move windows to the screen edges. The eight keys surrounding the “5” key move the current window to the edge of the screen. The “1” key moves the window to the upper left, the “8” key moves it to the top, etc. With a “shift” modifier, the windows move and also resize to half the screen width. The “0” key is wide, so it makes the current window as wide as possible. The “enter” key is tall, so it makes the current window as tall as possible. Just as an extra, the “.” key opens and positions a new Terminal window.

I use these keys a lot. They are easy to remember because of the physical layout of the numeric keypad.

1 Like

Ooops, here's that library. :smile:Window-Movers.kmlibrary (40.0 KB)

Thanks for this Pete, as I use the numeric keypad a little I’ve added an enable/disable function with Esc key. Don’t know if you meant to include other libraries or not, only there are several others besides Window Movers.

Duncmac,
Could you please elaborate on how you use the escape key to enable/disable?

Since I posted I modified it slightly and now press ⌃Esc as it obviously interfered with normal Esc key use.

Pressing ⌃Esc acts as a Disable/Enable toggle.

Here's what I did:

1 Like

Thanks for that!

Thanks siemsen and duncmac for your posts that have inspired me to develop a set of window sizing and positioning macros. While doing so I have run across some inconsistent behavior in KM.

My setup is a bit unorthodox: I use an Apple Bluetooth keyboard and a Bluetooth numeric keypad from OWC (http://eshop.macsales.com/item/NewerTech/KPA28BTW/).

Since I use the keypad a lot for numeric data entry and for its handy forward-delete, home, end, and page up and page down keys, I wanted to map ^-number keys to the window sizing macros: for example, ^-6 to move a window to the right half of the screen at full screen height. The numeric keypad does not have a control key, and it is perhaps not surprising that (using ^-6 as an example) a Hot Key Trigger does not recognize the key combination of [Apple wireless keyboard]^-[numeric keypad]6, because the key codes are generated by two different devices.

Here's the inconsistency: a Device Key trigger allows me to type number pad-6 and enable Apple keyboard-control as a modifier, and the keystroke in the Macros column updates to (evidently) show the selected mapping of [Apple wireless keyboard]^-[numeric keypad]6 (see the screen shot). But, the macro is not invoked, which again, is perhaps not surprising, but given that the KM editor allows me to enable this key combination using two devices, is confusing. It is evident that the numeric keypad is recognized by OS X and generates the proper keycodes, so this is not the problem.

So, I wonder if there is some way that I'm not seeing to use the control key on the Apple wireless keyboard in conjunction with the OWC numeric keypad as KM macro triggers?

(As a work-around, I have put all of the macros in a group and set it up to show/hide a palette when the hotkey when cmd-esc is pressed.)

Thanks.

Thanks siemsen!
Helpt me!

That should work fine.

The control key requirement is based on the current modifier settings, so it has nothing to do with which keyboard is being used for what. If the control key is down, then the current modifiers should be correct.

If you configure a macro group to be showing a palette, then the macros will be active only when that palette is displayed so that may be part of the problem.

My suggest would be:

  • Change the trigger to "ignoring modifiers" - does it work?
  • Change the trigger to "with these modifiers, all off" - does it work?
  • Change the trigger to "with these modifiers, control key (as displayed)" - does it work?

If the first two work and the last one does not, then I will ponder further.

Keep in mind though, that Device Key triggers do not swallow the key stroke. So this is going to result in a 6 or a Control-6 being sent to the front application.

Thanks for your reply.

You noted: “If you configure a macro group to be showing a palette, then the macros will be active only when that palette is displayed so that may be part of the problem.”

While testing I set the Group to “Available in all applications” and “Always activated”, so the palette is not invoked (and also ensured that the macro is enabled…).

I tested all combinations of Hot Key and Device key, using the external keypad and the Apple keyboard. Summarized results:

– All cases using the Apple wireless keyboard work as expected (except for perhaps the last case, see the ??? note)
– Using Hot Key [any modifier]-[keypad]-6 does not work as expected: [any modifier]-[keypad]6 is treated the same as [no modifier]-[keypad]6
– Using Device Trigger [any modifier]-[keypad]-6 does not work as expected: [selected modifier]-[keypad]6 does nothing
– All other cases using the keypad appear to work as expected.

Test cases & results:

---- Using Hot Key trigger:

This hot key: [any modifier]-[keypad]6
Hot Key box shows: "Key Pad 6"
Result: [selected or any modifier]-[keypad]6 and [keypad]6 move a window – that is to say that [any modifier]-[keypad]6 is treated the same as [no modifier]-[keypad]6
incorrect behavior

This Hot Key: [any modifier]-[Apple keyboard]6
Hot Key box shows: [selected modifier]-6
Result: only [selected modifier]-6 moves a window
– correct behavior

---- Using Device Trigger, ignoring modifiers:

This device key: [keypad]6
Device key box shows: "Aluminum Number Pad Key Pad 6"
Result: [keypad]6 with no, any, or any combination of modifiers moves a window – that is to say that (as expected) modifiers are ignored
– correct behavior
and as you point out, the 6 keystroke is not swallowed
– correct behavior

This device key: [any modifier]-[Apple keyboard]6
Device Key box shows: “Apple Wireless Keyboard 6 and ^6” (meaning both the 6 and shift key-6 keystroke, “^”)
Result: [Apple keyboard]6 with no, any, or any combination of modifier moves a window – that is to say that (as expected) modifiers are ignored
– correct behavior
and as you point out, the 6 keystroke is not swallowed
– correct behavior

---- Using Device Trigger, with any modifier:

This device key: [any modifier]-[keypad]6
Device Key box shows “Aluminum Number Pad Key Pad 6” and no modifier box is selected, and when a modifier is selected, its box is shaded (which appears to be normal behavior)
Result: [selected modifier]-[keypad]6 does nothing
incorrect behavior
and as you point out, the 6 keystroke is not swallowed
– correct behavior

This device key: [any modifier]-[Apple keyboard]6
Device key box shows “Apple Wireless Keyboard 6 and ^” (meaning both the 6 and shift key-6 keystroke, “^”)
Result: [selected modifier]-[Apple keyboard]6 move a window, but [shift][selected modifier]-[Apple keyboard]-6 does nothing
– ???correct behavior???
and as you point out, the 6 keystroke is not swallowed (if it is a displayable character, otherwise no character is displayed)
– correct behavior

I forgot to mention:

I have rebooted several times during the course of testing. Same results.

I logged in using the shift key to prevent login items from loading and conducted a round of testing. Same results.

I disabled the ^-number Mission Control keystrokes in Sys Prefs>Keyboard>Mission Control. Same results

Take a look at Witch. Very flexible and powerful tool for managing windows and layouts.

thank you for this macro library! I have a question: for me this moves the window to the other monitor. Is there a way to keep it on the same monitor?

No, I don't think there's a way to keep it on the same monitor, sorry.

Hey @devananda,

I don't see why not.

These are all based on screen calculations, so you should be able to make them do pretty much what you want them to with a little tweaking.

-Chris

Riding the coattails of moving windows, I’ve found using BetterTouchTool (BTT) (touted elsewheres within this forum) and a large Apple trackpad to be an excellent window positioning combo. A single finger tap in one of the four corners of the trackpad moves the active window to that corner of the screen and resizes it to 1/4 of the current screen size. A four finger swipe left or right resizes the active window to the respective right or left half of the screen.

These are just the gestures and sizes I picked from many options available within BTT. IF (I haven’t tried) it plays well with multiple monitors at different resolutions AND you work well more gesture-centricly, it may work for your more complex needs.

1 Like