User Submitted Macro

Swap Monitors for Current Window

Written by David Taylor

What it does

If multiple monitors are present, moves the current window to the next monitor. If there are 3 or more monitors, the window will be cycled through them in order, each time the macro is run.

To install

Download the macro file umswapmonitorsforcurrentwindow.mex and save it to your hard drive where you store your macro file(s). If desired, import the macro into your existing macro file by clicking File, Import, Import Macros.

To use

If you imported it into your macro file, then you can run it from within Macro Express. Hotkey Ctrl+Shift+M is pre-set for this macro, however you can alter the hotkey using the macro editor.

How it works

When triggered, the total number of monitors are counted. If there is only 1 monitor, the macro exits without taking any action. If there are 2 or more screens, the currently active window is moved to the next monitor in sequence. If there are 3 or more displays, the window is moved to the next monitor, each time the macro is triggered (eg, for 3 screens, it would move to 1, then 2, then 3, than 1 again, each time the macro is run).

If the target screen resolution is smaller than the window being moved, then the window is also resized to fit the target screen. If the window is currently Maximized, it will remain so on the new monitor. Likewise, if the window is NOT maximized, then it is simply positioned in the center of the target monitor, with the window size left alone (unless too large for the screen, of course).

Most of the variables, conditions, and modifications in the macro are present mainly to ensure the window fits properly on the target monitor.

Requirements

Macro Express Pro