icuurd12b42 wrote:you can post message WM_SYSCOMMAND with SC_SIZE to the window. That will have the effect, like try in notepad, of clicking the Size menu in the window system menu. basically you wont have to do anything but send/post that message once
You mean this:
Code: Select all
PostMessage, 0x0112, 0xF000, 0, , ahk_id %window_id%
which is equivalent to,
Code: Select all
WinMenuSelectItem, ahk_id %window_id%,,0&, Size
?
I am not quite sure if this has the interactive effect I am shooting for. It needs a subsequent arrow key input and mouse drag. Imagine the right hand being on the mouse, lifting up back to keyboard to strike an arrow-combo, then back to the mouse again. This is "tedious". I suspect a creative solution is possible that relies on this (would love to get my hands on one), but just sending the message isn't sufficient I am afraid.
The script I am hoping to achieve helps with many-windows-on-a-large-4K-monitor workflow, where windows are moved and resized with ease, especially those that don't present an easy way to resize/move (for example do you ever use the "post-it" mode on Notepad++?). Basically the following:
0. Left hand is on the keyboard, right hand is on the mouse, moving around windows.
1. Left hand presses a convenient key combination, and mouse right-click-drag resizes the window it is hovering over. (left-click-drag moves the window)
2. The initial move in the mouse determines which corner or edge to drag around.
3. Mouse button release terminates the loop
Here is a my attempt at a script that accomplishes this - very ugly and does not quite "feel right", but works to the extent that I still prefer this over menu-resize. And currently, one issue is this WinMove based resize flickering:
Code: Select all
; ctrl+alt while right-click drag to resize the window
^!RButton::
CoordMode, Mouse, Screen
MouseGetPos, mx0, my0, window_id
WinGetPos, wx, wy, ww, wh, ahk_id %window_id%
WinGet, window_minmax, MinMax, ahk_id %window_id%
; Restore the window if maximized
if (window_minmax > 0)
{
WinRestore ahk_id %window_id%
}
SetWinDelay, 0
firstDeltaX := "init"
firstDeltaY := "init"
while(GetKeyState("RButton","P")) {
; resize the window based on cursor position
MouseGetPos, mx, my
if(mx == mx0 && my == my0) {
continue
}
if( firstDeltaX == "init" && mx-mx0 <> 0 ) {
firstDeltaX := mx-mx0
}
if( firstDeltaY == "init" && my-my0 <> 0 ) {
firstDeltaY := my-my0
}
deltaX := mx - mx0
deltaY := my - my0
if(firstDeltaX<0) {
ww += deltaX
}
else if (firstDeltaX>0) {
wx += deltaX
ww -= deltaX
}
if(firstDeltaY<0) {
wh += deltaY
}
else if (firstDeltaY>0) {
wy += deltaY
wh -= deltaY
}
mx0 := mx
my0 := my
WinMove ahk_id %window_id%,, wx, wy, ww, wh
}
return
For left-click-drag window move I am using
this neat script by Lasmori, which was also the inspiration for the above.
Any other ideas are very much appreciated!
Thanks for the help.