Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

KDE / FVM like resize


  • Please log in to reply
6 replies to this topic
thinkstorm
  • Members
  • 40 posts
  • Last active: Sep 10 2014 06:06 PM
  • Joined: 17 Aug 2004
Hi all,
the following code resizes a window when you ALT+RightClick into it. It acutally resizes the corner your mouse is most near when you start the operation, so when your mouse for example is near the upper left corner, the window is resized in the upper left side.
The 'if' constructs seem to be stupid (a simple intelligent add would work, too), but it speeds things up a lot, as no mouse movement is also detected (and not reacted on).
______________________________________________

!RButton::
    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, RButton, 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


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
I tried this one too; it took me a while to figure out that you have to DRAG while holding down the Alt key to get the window to resize.

It's a nice script and does a good job avoiding the need to grab onto those tiny corners of the window when you want to resize it. I might have to apply this one to my own script.

Thanks for sharing all of these scripts.

WhiteCloud
  • Members
  • 68 posts
  • Last active: Feb 06 2005 05:55 PM
  • Joined: 19 Jun 2004
very interesting scripts,

Thanks thinkstorm
AHK = Hella fun

thinkstorm
  • Members
  • 40 posts
  • Last active: Sep 10 2014 06:06 PM
  • Joined: 17 Aug 2004
BTW: as you might have noticed, you can also drag-size the window while it is in the background / inactive. This wasn't exactly intended, but is a nice feature :)

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Partially inspired by this topic, Jonny has posted the first version of his ultimate KDE-style window dragging/resizing script. If you have an interest, please give it a try and post feedback. http://www.autohotke...opic.php?t=2062

innn
  • Members
  • 8 posts
  • Last active: Mar 15 2014 06:55 AM
  • Joined: 16 Mar 2012

Hi all,
the following code resizes a window when you ALT+RightClick into it.


hi all, I know this is so old but I find this script teh best of all I this script the best of all that I 've tried
and still use it
one question though is it too much to ask for one that moves the window with alt+left drag?
thank you

noname
  • Members
  • 650 posts
  • Last active:
  • Joined: 12 Nov 2011
You can use an existing one .

http://www.autohotke... ... wDrag_(KDE).htm

winXP  and ahk unicode