AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

KDE / FVM like resize

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
thinkstorm



Joined: 17 Aug 2004
Posts: 38

PostPosted: Tue Aug 17, 2004 6:12 pm    Post subject: KDE / FVM like resize Reply with quote

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).
______________________________________________

Code:
!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
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10716

PostPosted: Tue Aug 17, 2004 6:44 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Send e-mail
WhiteCloud



Joined: 19 Jun 2004
Posts: 68

PostPosted: Tue Aug 17, 2004 10:56 pm    Post subject: Reply with quote

very interesting scripts,

Thanks thinkstorm
_________________
AHK = Hella fun
Back to top
View user's profile Send private message
thinkstorm



Joined: 17 Aug 2004
Posts: 38

PostPosted: Wed Aug 18, 2004 2:55 am    Post subject: Reply with quote

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 :)
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10716

PostPosted: Mon Jan 31, 2005 1:22 pm    Post subject: Reply with quote

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.autohotkey.com/forum/viewtopic.php?t=2062
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group