J. P. Gilliver (John) wrote:
> (I'm on 7, but the problem applies to XP and 10 too, and the solution -
> if there is one! - may be universal.)
>
> Occasionally, I accidentally either move a window, or drag one of its
> sides, by mistake - while doing (or intending to) something else with
> the mouse pointer, it catches on an edge, or more likely a title bar.
> (Unlike a lot of people, I _don't_ operate most of my windows
> full-screen most of the time, so their relative sizes and positions are
> important to me.)
>
> I discovered fairly recently that _if I notice while the movement is in
> process_ (I just see the _outline_ move, i. e. I've still got the "mouse
> button pressed" [actually I use a touchpad, but similar applies]), I can
> cancel the move/resize by - keeping the button pressed and - pressing
> the Esc key. But if I don't - anyone know of a way of undoing a window
> move/resize? (Ctrl-Z doesn't seem to work.)
You already know about using the Esc key to abort the operation while it
is *in progress* (the mouse button is still pressed when Esc is hit).
That the window is getting moved or resized should be obvious before you
release the mouse button hence the Esc key is how you abort a
noncommitted operation. As Maya notes, there is no Undo (Ctrl+Z) for a
move/size operation after the operation has been committed. Too late
after releasing the mouse. Once you see the window resizing or moving,
do NOT release the mouse button! With a pending operation, you can
Esc(ape) it. When you have an Oops, keep the mouse button pressed to
let you un-Oops.
You have to break the habit of releasing the mouse button to afterward
seek how to revert the move or resize of a window. Don't release until
you're satisfied with the change, and don't release if you want to use
Esc to abort. Instinct has you back off (release).
Personally I don't rely on absolute positioning or sizing to stay fixed
for windows. Too many times when loading an app, the window opens
somewhere else than before. You cannot guarantee the window will always
open in the same spot unless the program itself lets you configure its
initial X-Y coordinates for the upper left corner along with size (which
could still run into a problem if the screen size is smaller than the
program's fixed window size). Plus, even if a program gave you that
option, it would only get enforced when the program's window was opened,
not prevent you later from moving or resizing that window. Trying to
load windows always in the same spot and always with the same size is an
exercise in futility if the program doesn't track a location history
even if just one history entry of where was the window and its size when
the window was last closed.
If you want windows to always open in the same spot, you need something
more for window management than Windows affords to the end user, like a
better window manager. I've heard of, but not used Desksoft's
WindowManager (
https://www.desksoft.com/WindowManager.htm). I'm sure I
could find other window managers if I bothered to hunt for them. That
window manager lets you configure where a window opens (don't know about
sizing), and even lock the window so it cannot be moved or resized.
I've also heard of, but not used, ShellFolderFix
(
https://www.majorgeeks.com/files/details/shellfolderfix.html).
ShellFolderFix works with some programs (Firefox, LibreOffice, Revo
Uninstaller), but not with some other programs (Thunderbird, CCleaner,
Irfanview). Up to you to discover with which program's window it can
manage their positioning.
Another option is to use a hotkey macro tool, like AutoHotkey or AutoIt,
that can position a window to a fixed coordinate for the upper left
corner and set a size on the window. You'd define a single hotkey that
has multiple rules depending on the titlebar's string (window name), and
each rule or condition would position that window for that program at
the same spot. I haven't used AutoHotkey for many years, but recall it
can interrogate the string for the titlebar, and it could position and
size the window. You'd have to define multiple conditions, or tests, in
the macro that would set position and size based on the titlebar. Alas,
many programs use the same titlebar string for multiple window opens by
the same program, so there's no way to distinguish one program's window
from another that it opened.
In a similar vein of using a macro with multiple conditions to test on
the titlebar string for where to position and size the currently focused
window, looks like WinSize2 can do that for you; see
http://winsize2.sourceforge.net/en/index.htm. Instead of having to
write a script with multiple conditions testing the titlebar string to
know on which window to effect positioning and sizing actions, you
record a table of windows in WinSize2 to do the same. However, it looks
like this tool triggers when a object.window is created; i.e., when a
window opens is when WinSize2 exercises its rules.
If you have Nirsoft's nircmd.exe tool, you can use it to set the
coordinates and size of an opened window by running:
nircmd.exe win setsize title "<titlebar>" <x> <y> <width> <height>
<titlebar> is the string on which to test in the titlebars of the
currently opened windows. <x> and <y> are the coordinates for the upper
left corner of the window. <width> and <height> are obvious. Values
are in pixels. No, the angle brackets are not part of the arguments.
Alas, Nirsoft didn't bother to document the win setsize arguments at
http://www.nirsoft.net/utils/nircmd.html; however, the nircmd.chm help
file does mention the win arg and its setsize parameter.
You could have a "Restore Windows" folder with a bunch of shortcuts, or
a toolbar in the Windows Taskbar, or other means of storing a multitude
of nircmds for the windows you are likely to open and might need to
reposition and resize.