Easy Resize Script: Fix

Posted: February 4, 2011 by jellymann in computers, fixes, hotkeys, keyboard, mouse, windows

I forgot something on my last post. The Easy Window Resize script I showed you had the same labels as the original Easy Window Move, so it didn’t work unless you ran them on separate scripts. The simple fix is to rename all the labels to unique ones. Otherwise, you can just use the fixed one below. I replaced all “EWD” with “EWR” and changed all “LButton” to “MButton”.

#MButton::
CoordMode, Mouse ; Switch to screen/absolute coordinates.
MouseGetPos, EWR_MouseStartX, EWR_MouseStartY, EWR_MouseWin
WinGetPos, EWR_OriginalPosX, EWR_OriginalPosY,,, ahk_id %EWR_MouseWin%
WinGet, EWR_WinState, MinMax, ahk_id %EWR_MouseWin%
if EWR_WinState = 0 ; Only if the window isn't maximized
SetTimer, EWR_WatchMouse, 10 ; Track the mouse as the user drags it.
return

EWR_WatchMouse:
GetKeyState, EWR_MButtonState, MButton, P
if EWR_MButtonState = U ; Button has been released, so drag is complete.
{
SetTimer, EWR_WatchMouse, off
return
}
GetKeyState, EWR_EscapeState, Escape, P
if EWR_EscapeState = D ; Escape has been pressed, so drag is cancelled.
{
SetTimer, EWR_WatchMouse, off
WinMove, ahk_id %EWR_MouseWin%,, %EWR_OriginalPosX%, %EWR_OriginalPosY%
return
}
; Otherwise, reposition the window to match the change in mouse coordinates
; caused by the user having dragged the mouse:
CoordMode, Mouse
MouseGetPos, EWR_MouseX, EWR_MouseY
WinGetPos, EWR_WinX, EWR_WinY, EWR_WinW, EWR_WinH, ahk_id %EWR_MouseWin%
SetWinDelay, -1 ; Makes the below move faster/smoother.
if (EWR_MouseX-EWR_WinX) <= (EWR_WinW/3)
{
if (EWR_MouseY-EWR_WinY) <= (EWR_WinH/3)
{
WinMove, ahk_id %EWR_MouseWin%,, EWR_WinX + EWR_MouseX - EWR_MouseStartX, EWR_WinY + EWR_MouseY - EWR_MouseStartY, EWR_WinW + EWR_MouseStartX - EWR_MouseX, EWR_WinH + EWR_MouseStartY - EWR_MouseY
}
else if (EWR_MouseY-EWR_WinY) <= (EWR_WinH/3)*2
{
WinMove, ahk_id %EWR_MouseWin%,, EWR_WinX + EWR_MouseX - EWR_MouseStartX, , EWR_WinW + EWR_MouseStartX - EWR_MouseX,
}
else
{
WinMove, ahk_id %EWR_MouseWin%,, EWR_WinX + EWR_MouseX - EWR_MouseStartX, , EWR_WinW + EWR_MouseStartX - EWR_MouseX, EWR_WinH + EWR_MouseY - EWR_MouseStartY
}
}
else if (EWR_MouseX-EWR_WinX) <= (EWR_WinW/3)*2
{
if (EWR_MouseY-EWR_WinY) <= (EWR_WinH/2)
{
WinMove, ahk_id %EWR_MouseWin%,,, EWR_WinY + EWR_MouseY - EWR_MouseStartY,, EWR_WinH + EWR_MouseStartY - EWR_MouseY
}
else
{
WinMove, ahk_id %EWR_MouseWin%,,,,, EWR_WinH + EWR_MouseY - EWR_MouseStartY
}
}
else
{
if (EWR_MouseY-EWR_WinY) <= (EWR_WinH/3)
{
WinMove, ahk_id %EWR_MouseWin%,,, EWR_WinY + EWR_MouseY - EWR_MouseStartY, EWR_WinW + EWR_MouseX - EWR_MouseStartX, EWR_WinH + EWR_MouseStartY - EWR_MouseY
}
else if (EWR_MouseY-EWR_WinY) <= (EWR_WinH/3)*2
{
WinMove, ahk_id %EWR_MouseWin%,,, , EWR_WinW + EWR_MouseX - EWR_MouseStartX,
}
else
{
WinMove, ahk_id %EWR_MouseWin%,,, , EWR_WinW + EWR_MouseX - EWR_MouseStartX, EWR_WinH + EWR_MouseY - EWR_MouseStartY
}
}
EWR_MouseStartX := EWR_MouseX ; Update for the next timer-call to this subroutine.
EWR_MouseStartY := EWR_MouseY
return

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s