AutoHotkey Community

It is currently May 27th, 2012, 12:31 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: KDE / FVM like resize
PostPosted: August 17th, 2004, 7:12 pm 
Offline

Joined: August 17th, 2004, 7:05 pm
Posts: 38
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 17th, 2004, 7:44 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 17th, 2004, 11:56 pm 
Offline

Joined: June 19th, 2004, 9:02 pm
Posts: 68
very interesting scripts,

Thanks thinkstorm

_________________
AHK = Hella fun


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 18th, 2004, 3:55 am 
Offline

Joined: August 17th, 2004, 7:05 pm
Posts: 38
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 :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 31st, 2005, 2:22 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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


Report this post
Top
 Profile  
Reply with quote  
PostPosted: March 16th, 2012, 7:25 am 
Offline

Joined: March 16th, 2012, 7:12 am
Posts: 4
thinkstorm wrote:
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 16th, 2012, 12:47 pm 
Offline

Joined: November 12th, 2011, 2:24 pm
Posts: 121
You can use an existing one .

http://www.autohotkey.com/docs/scripts/ ... wDrag_(KDE).htm


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Cristi®, Google Feedfetcher, tidbit and 56 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group