WindowDual: Move and Resize windows with one or two screens


This sets of macros is designed mainly to work with TWO screens, an INTERNAL screen on you macbook and an EXTERNAL Monitor. If you have more than two screens, the macros can be adapted. See Keyboard Maestro wiki for Screenvisible parameters.

However, all the macros will work if you ONLY HAVE ONE SCREEN. Some actions will not make sense but some e.g. almost maximise screen will work fine on just the internal.

I repeat they will work with ONE or TWO screens, maybe more.

The version has been tested with the External screen higher than the Internal screen.

The hotkeys used are as follows, but you can change these as required.
CC+key is CTL+CMD+key
OC+key is OPT+CMD+key, usually enabled as an alternative
Status is the Keyboard status menu
§ is the Section Key.

The macro group provides the following functions :

CC+§ Macro Palette Group
CC+/ README/HELP , Version History, SCREENVISIBLE info
Status Sets a override for the Target screen
NONE = No override, Window stays on CURRENT screen
INTERNAL = Moves window to INTERNAL screen
EXTERNAL = Moves window to EXTERNAL screen.
This is called from the status menu or the Macro Palette.
It also sets a debug level,
NONE = NO debug trace
DW= Display certain notifications and alerts
I have left limited debug in so if you modify it, you know what is going on.

CC+ [ Move window to left half of screen
CC+ ] Move window to right half of screen
CC+ ' (Single quote) Move window to centre of screen (but 50% wide)

CC+ - (Minus) Minimise Window

CC+ + (Plus) This almost maximises the window but leaves a 10-15 pixel border all round it. I find this makes it easier to click/drag the scroll bars and it keeps the top level menu bar visible.

CC+; Resizes the window to about a 25% and tiles it on the INTERNAL screen in two rows of 5 columns.

The containing macro group should be active in ALL applications. .

Note: For small screens, it will not resize to less than the window minimum width
eg Keyboard Maestro editor is always nnnn or more pixels wide,
which may be more than say 60% of the width of the screen


ScreenVisible function

This is to unravel the mysteries of the ScreenVisible function.

Assume you have two screens Int and Ext.
Int is 800h x 400w
Ext is 1000h x 1600w

You define their arrangement in System Preferences > Displays > Arrangement.

Assume that you put the Ext above the Int and 30% to the left,
and give the horizontal white info/menu bar to the Int screen

OK, now whichever screen has the white bar is the Master screen.

0,0 and zero is defined as the absolute top left corner of the Master screen

Next the width and height of Int and Ext are not going to change …. ever** ,
so ScreenVisible( Internal, Width) and ScreenVisible( Internal, Height) will always give you the same answer.

Top and Height are the only two we need to worry about

So if the INT screen is the master, left will be 0, and top will be 0 as well
The bottom left of the Int screen will be 0 , 800 i.e. the left side of the screen is 0
The bottom right will be 400, 800 i.e. 400 down, 800 across to the right

Ok so here is where it gets weird

The top of the EXT screen will now be the top of the Int screen i.e. ( 0) plus the height of the EXT monitor i.e. 1000,
BUT as we are going up, the value is -1000. !!! NEGATIVE.

Similarly if the arrangement has the External Monitor say 30% to the left, then the LEFT edge of the EXT monitor will be 0 (left the INT) + the offset
Say the offset is 30% of 1000 i.e. 333 pixels

Then the left hand edge is 0 + offset = 0 = ( -333) = -333 i.e. NEGATIVE !!

Then the coords of EXT Left top corner are -333 and -1000. Both negative.

So when you resize with Keyboard Maestro, it knows which screen as it knows the coordinate relative to the Master.

If your screen is side by side, then the same general principles apply.

You can try out different arrangements by modifying the Displays arrangement, remember you do NOT have to physically move the monitors just the virtual arrangement.

Finally, as we are using ScreenVisible and not the Screen function, Screenvisible allows about 30 pixels for the height of the top menu bar on the Master screen, and reduces the height available by 30. So if EXT was the master, height would be 1000-30 = 970 pixels. ** above was not strictly correct.

JGLp WindowDual: Move and Resize windows with one or two Screens Macros v1_00 .kmmacros (92.2 KB)