window drag resize script update Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
dayno

window drag resize script update

17 Aug 2017, 17:02

hi guys,

I am trying to update this original script from chris to use different shortcuts:

Code: Select all

!MButton::
    CoordMode, Mouse, Relative
    MouseGetPos, inWinX, inWinY, WinId
    if WinId =
        return
    WinGetPos, winX, winY, winW, winH, ahk_id %WinId%
    halfWinW = %winW%
    EnvDiv, halfWinW, 2
    halfWinH = %winH%
    EnvDiv, halfWinH, 2
    if inWinX < %halfWinW%
        MousePosX = left
    else
        MousePosX = right
    if inWinY < %halfWinH%
        MousePosY = up
    else
        MousePosY = down
    CoordMode, Mouse, Screen
    MouseGetPos, OLDmouseX, OLDmouseY, WinId
    SetWinDelay, 0 
    Loop
    {
        GetKeyState, state, ALT, P
        if state = U
            break
        GetKeyState, state, MButton, P
        if state = U
            break
        MouseGetPos, newMouseX, newMouseY 
        if newMouseX < %OLDmouseX% 
        { 
            Xdistance = %OLDmouseX% 
            EnvSub, Xdistance, %newMouseX%
            if MousePosX = left ; mouse is on left side of window
            {
                EnvSub, winX, %Xdistance%
                EnvAdd, winW, %Xdistance%
            }
            else
            {
                EnvSub, winW, %Xdistance%
            }
        } 
        else if newMouseX > %OLDmouseX% 
        { 
            ; mouse was moved to the right 
            Xdistance = %newMouseX% 
            EnvSub, Xdistance, %OLDmouseX%    
            if MousePosX = left ; mouse is on left side of window
            {
                EnvSub, winW, %Xdistance%
                EnvAdd, winX, %Xdistance% 
            }
            else
            {
                EnvAdd, winW, %Xdistance%
            }
        }
        OLDmouseX = %newMouseX% 
        if newMouseY < %OLDmouseY% 
        { 
            Ydistance = %OLDmouseY% 
            EnvSub, Ydistance, %newMouseY%    
            if MousePosY = up ; mouse is on upper side of windows
            {
                EnvSub, winY, %Ydistance%
                EnvAdd, winH, %Ydistance%
            }
            else
            {
                EnvSub, winH, %Ydistance%
            }
        } 
        else if newMouseY > %OLDmouseY% 
        { 
            Ydistance = %newMouseY% 
            EnvSub, Ydistance, %OLDmouseY%    
            if MousePosY = up ; mouse is on upper side of windows
            {
                EnvAdd, winY, %Ydistance%
                EnvSub, winH, %Ydistance%
            }
            else
            {
                EnvAdd, winH, %Ydistance%
            }
        } 
        OLDmouseY = %newMouseY%
        WinMove, ahk_id %WinID%,,%winX%,%winY%,%winW%,%winH% 
    }
return
This currently resizes windows by pressing ALT+MButton, Is there a way to use LWin instead of Alt?

I don't seem to be able to make it work in that way.

Thank you!
D
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: window drag resize script update

17 Aug 2017, 17:53

1) replace in the first line: !MButton:: with #MButton::
2) replace in line 23: GetKeyState, state, ALT, P with GetKeyState, state, LWin, P
I hope that helps.
User avatar
Cerberus
Posts: 172
Joined: 12 Jan 2016, 15:46

Re: window drag resize script update  Topic is solved

17 Aug 2017, 19:33

In addition to what Wolf said, if you want it to work only with the left Windows key, use <# instead of #.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, Google [Bot], hiahkforum, jchestnut, mcd, Sem552, ShatterCoder and 110 guests