AutoHotkey Community

It is currently May 25th, 2012, 3:30 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 51 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
 Post subject:
PostPosted: June 20th, 2006, 5:02 am 
Is it just me or does the window jump back and forth between its original position and its new position while you're holding alt and dragging? It's erratic and jarring. I've tried it on three different copies of Windows XP.

-Phil Crosby


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2006, 7:50 am 
@ Phil
please use a nick. You don't have to register for it. Thx for listening. :)


Report this post
Top
  
Reply with quote  
PostPosted: July 4th, 2006, 6:58 am 
hi,

I have placed EasyWindowDrag_(KDE).ahk in my startup folder. I see
that it gets loaded at start up time by the presence of the AHK icon in system tray.

Even though it is loaded, it doesn't function as it should until I manually reload the script. This is the case each & every time my computer boots up.

can someone explain what the problem could be ? I'm running Windows XP (SP 2) and version 1.0.43.06 of AHK.

Thanks
--Andrew


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 4th, 2006, 9:23 am 
Offline

Joined: August 24th, 2005, 5:17 pm
Posts: 1237
I'd guess that you have another script which uses the same hotkeys and is loading after this script, hence "grabbing" the hotkeys for itself. Reloading this script would cause it to grab the hotkeys back.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 6th, 2006, 6:07 pm 
i'm not sure how worth it is, but i noticed that WinMove section of resize can be optimized like this:

from:
Code:
If (KDE_X1 < KDE_WinX1 + KDE_WinW / 2)
   KDE_WinLeft := true
Else
   KDE_WinLeft := false
If (KDE_Y1 < KDE_WinY1 + KDE_WinH / 2)
   KDE_WinUp := true
Else
   KDE_WinUp := false


to:
Code:
If (KDE_X1 < KDE_WinX1 + KDE_WinW / 2)
   KDE_WinLeft := 1
Else
   KDE_WinLeft := -1
If (KDE_Y1 < KDE_WinY1 + KDE_WinH / 2)
   KDE_WinUp := 1
Else
   KDE_WinUp := -1



and from:
Code:
   If KDE_WinLeft
   {
      ; Reverse and apply the offset to the size, and correct for the skewed position.
      KDE_WinX1 += KDE_X2
      KDE_WinW -= KDE_X2
   }
   Else
      KDE_WinW += KDE_X2 ; Apply the offset to the size.
   If KDE_WinUp
   {
      ; Reverse and apply, correct the position.
      KDE_WinY1 += KDE_Y2
      KDE_WinH -= KDE_Y2
   }
   Else
      KDE_WinH += KDE_Y2 ; Apply the offset.
   ; Finally, apply all the changes to the window.
   WinMove,ahk_id %KDE_id%,,%KDE_WinX1%,%KDE_WinY1%,%KDE_WinW%,%KDE_WinH%


to:
Code:
WinMove,ahk_id %KDE_id%,,% KDE_WinX1+(KDE_WinLeft+1)/2*KDE_X2, KDE_WinY1+(KDE_WinUp+1)/2*KDE_Y2, KDE_WinW-KDE_WinLeft*KDE_X2,  KDE_WinH-KDE_WinUp*KDE_Y2


some arithmetic stuff :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 6th, 2006, 7:10 pm 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
As a showcase script, the main goal is readability and learnability (word? :D ), so I think the first one should stay as is. However, I like the second one. It seems both faster and more readable. 8)

Have you already tested it?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 7th, 2006, 7:42 am 
yeah it works fine.
i'm now studying AHK with those nice showcase scripts, and really happy to use them.
by the way, i found more understandable expression. just split :)

Code:
WinMove,ahk_id %KDE_id%,,% KDE_WinX1 + (KDE_WinLeft+1)/2*KDE_X2  ; X of resized window
                         , KDE_WinY1 +   (KDE_WinUp+1)/2*KDE_Y2  ; Y of resized window
                         , KDE_WinW  -     KDE_WinLeft  *KDE_X2  ; W of resized window
                         , KDE_WinH  -       KDE_WinUp  *KDE_Y2  ; H of resized window


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 8th, 2006, 5:37 am 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
I fiddled around with this in my spare time for two days before finally realizing I needed that first optimization of yours to make the second one work. I was trying to find a way to do that arithmetic with the '0' and '1' values, and eventually decided to just change those to '-1' and '1'... and my mind snapped back to your suggestions. I probably should've questioned why you changed the false's to -1's.... :roll:

Anyway, I included both optimizations and voila, works like a charm. Much thanks for the improvement, I'll see that it's added to the showcase version.

This is some great expression practice, too. 8)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 9th, 2006, 2:45 am 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
Both the showcase version and the [synchronous] version in the first post of this topic have been updated. Enjoy!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 16th, 2007, 6:29 pm 
Anonymous wrote:
Is it just me or does the window jump back and forth between its original position and its new position while you're holding alt and dragging? It's erratic and jarring. I've tried it on three different copies of Windows XP.

-Phil Crosby


Yes, it does the same on my comp. (WIN2000)

AFAIK Windows can be switched into dragmove mode, which could be more "natural" to the system.


Report this post
Top
  
Reply with quote  
PostPosted: April 6th, 2007, 7:48 pm 
I hacked this script to use double-clicks instead of doubleAlts:
Code:
KDE_Alt_Left_Tick = 0
.
.
.
!LButton::
; Get the initial mouse position and window id, and
; abort if the window is maximized.
MouseGetPos,KDE_X1,KDE_Y1,KDE_id
WinGet,KDE_Win,MinMax,ahk_id %KDE_id%
If (KDE_Win) {
    if ( (A_TickCount - KDE_Alt_Left_Tick) <300) {
        WinRestore,ahk_id %KDE_id%
        return
    } else {
        KDE_Alt_Left_Tick = %A_TickCount%
        return
    }
   
} else {
    if ( (A_TickCount - KDE_Alt_Left_Tick) <300) {
        WinMaximize,ahk_id %KDE_id%
        return
    } else {
        KDE_Alt_Left_Tick = %A_TickCount%
        ; don't return!
    }
}


And similar code to minimize on Alt right double click.

This is a lot more intuitive for me, probably because I've never used KDE.
That's the cool thing about scripts; in a certain sense it's all configuration, nothing's really hard-coded.

I think you've made a great script here; I use it as example when preaching the wonders of AutoHotKey to coworkers. :D


Report this post
Top
  
Reply with quote  
 Post subject: jumping windows???
PostPosted: May 3rd, 2007, 5:03 am 
Anonymous wrote:
Is it just me or does the window jump back and forth between its original position and its new position while you're holding alt and dragging? It's erratic and jarring. I've tried it on three different copies of Windows XP.

-Phil Crosby


I noticed the same problem after modifying the script. Although the modification does not have any thing to do with the hot key. to illustrate, I am using WIN+LButton to drag and WIN+RButton to move and the script worked just fine.

However, after adding the following lines, the behaviour of dragging and resizing became wiered:
Code:
SystemDoubleClickTime := DllCall("GetDoubleClickTime")
Ctrl::
   If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < SystemDoubleClickTime) {
         send ^!r
   }
return

this simply hook a double-press of the Ctrl key
although it has nothing to do with the WIN key,, it is still giving this wiered behaviour!!!

any suggestions??
-khalid


Report this post
Top
  
Reply with quote  
PostPosted: September 20th, 2007, 4:27 pm 
Iulian wrote:
I would like to use your script, but I also like Alt-Tab Replacement
( http://file.autohotkey.net/evl/AltTab/AltTab.ahk ).
Running both scripts, makes imposible the selection in the task list
(alt+left click) because the kde window moving is triggered.
Is there an work around for this ?

Iulian T.


I customized this window dragging/resizing script to use Ctrl instead of Alt. The only modification other than changing all "!" to "^" and "Alt" to "Ctrl" was to add a ~ in front of ^LButton. This allows you to still use the Ctrl + click to select different files that aren't next to each other. Here's the script with Ctrl:

Code:
/*
AHK Version: 1.0.47.03
Language:    English
Platform:    Win9x/NT
Author:     
*/

#SingleInstance force

; This script was inspired by and built on many like it
; in the forum. Thanks go out to ck, thinkstorm, Chris,
; and aurelian for a job well done.

; Change history:
; November 07, 2006: Optimized resizing code in ^RButton, courtesy of bluedawn.
; February 05, 2006: Fixed double-Ctrl (the ~Ctrl hotkey) to work with latest versions of AHK.

; The Double-Ctrl modifier is activated by pressing
; Ctrl twice, much like a double-click. Hold the second
; press down until you click.
;
; The shortcuts:
;  Ctrl + Left Button  : Drag to move a window.
;  Ctrl + Right Button : Drag to resize a window.
;  Double-Ctrl + Left Button   : Minimize a window.
;  Double-Ctrl + Right Button  : Maximize/Restore a window.
;  Double-Ctrl + Middle Button : Close a window.
;
; You can optionally release Ctrl after the first
; click rather than holding it down the whole time.

If (A_AhkVersion < "1.0.39.00")
{
    MsgBox,20,,This script may not work properly with your version of AutoHotkey. Continue?
    IfMsgBox,No
    ExitApp
}


; This is the setting that runs smoothest on my
; system. Depending on your video card and cpu
; power, you may want to raise or lower this value.
SetWinDelay,2

CoordMode,Mouse
return

~^LButton::
If DoubleCtrl
{
    MouseGetPos,,,KDE_id
    ; This message is mostly equivalent to WinMinimize,
    ; but it avoids a bug with PSPad.
    PostMessage,0x112,0xf020,,,ahk_id %KDE_id%
    DoubleCtrl := false
    return
}
; Get the initial mouse position and window id, and
; abort if the window is maximized.
MouseGetPos,KDE_X1,KDE_Y1,KDE_id
WinGet,KDE_Win,MinMax,ahk_id %KDE_id%
If KDE_Win
    return
; Get the initial window position.
WinGetPos,KDE_WinX1,KDE_WinY1,,,ahk_id %KDE_id%
Loop
{
    GetKeyState,KDE_Button,LButton,P ; Break if button has been released.
    If KDE_Button = U
        break
    MouseGetPos,KDE_X2,KDE_Y2 ; Get the current mouse position.
    KDE_X2 -= KDE_X1 ; Obtain an offset from the initial mouse position.
    KDE_Y2 -= KDE_Y1
    KDE_WinX2 := (KDE_WinX1 + KDE_X2) ; Apply this offset to the window position.
    KDE_WinY2 := (KDE_WinY1 + KDE_Y2)
    WinMove,ahk_id %KDE_id%,,%KDE_WinX2%,%KDE_WinY2% ; Move the window to the new position.
}
return

^RButton::
If DoubleCtrl
{
    MouseGetPos,,,KDE_id
    ; Toggle between maximized and restored state.
    WinGet,KDE_Win,MinMax,ahk_id %KDE_id%
    If KDE_Win
        WinRestore,ahk_id %KDE_id%
    Else
        WinMaximize,ahk_id %KDE_id%
    DoubleCtrl := false
    return
}
; Get the initial mouse position and window id, and
; abort if the window is maximized.
MouseGetPos,KDE_X1,KDE_Y1,KDE_id
WinGet,KDE_Win,MinMax,ahk_id %KDE_id%
If KDE_Win
    return
; Get the initial window position and size.
WinGetPos,KDE_WinX1,KDE_WinY1,KDE_WinW,KDE_WinH,ahk_id %KDE_id%
; Define the window region the mouse is currently in.
; The four regions are Up and Left, Up and Right, Down and Left, Down and Right.
If (KDE_X1 < KDE_WinX1 + KDE_WinW / 2)
   KDE_WinLeft := 1
Else
   KDE_WinLeft := -1
If (KDE_Y1 < KDE_WinY1 + KDE_WinH / 2)
   KDE_WinUp := 1
Else
   KDE_WinUp := -1
Loop
{
    GetKeyState,KDE_Button,RButton,P ; Break if button has been released.
    If KDE_Button = U
        break
    MouseGetPos,KDE_X2,KDE_Y2 ; Get the current mouse position.
    ; Get the current window position and size.
    WinGetPos,KDE_WinX1,KDE_WinY1,KDE_WinW,KDE_WinH,ahk_id %KDE_id%
    KDE_X2 -= KDE_X1 ; Obtain an offset from the initial mouse position.
    KDE_Y2 -= KDE_Y1
    ; Then, act according to the defined region.
    WinMove,ahk_id %KDE_id%,, KDE_WinX1 + (KDE_WinLeft+1)/2*KDE_X2  ; X of resized window
                            , KDE_WinY1 +   (KDE_WinUp+1)/2*KDE_Y2  ; Y of resized window
                            , KDE_WinW  -     KDE_WinLeft  *KDE_X2  ; W of resized window
                            , KDE_WinH  -       KDE_WinUp  *KDE_Y2  ; H of resized window
    KDE_X1 := (KDE_X2 + KDE_X1) ; Reset the initial position for the next iteration.
    KDE_Y1 := (KDE_Y2 + KDE_Y1)
}
return

; "Ctrl + MButton" may be simpler, but I
; like an extra measure of security for
; an operation like this.
^MButton::
If DoubleCtrl
{
    MouseGetPos,,,KDE_id
    WinClose,ahk_id %KDE_id%
    DoubleCtrl := false
    return
}
return

; This detects "double-clicks" of the Ctrl key.
~Ctrl::
DoubleCtrl := A_PriorHotKey = "~Ctrl" AND A_TimeSincePriorHotkey < 400
Sleep 0
KeyWait Ctrl  ; This prevents the keyboard's auto-repeat feature from interfering.
return


That should free up your Alt key for the Alt + Tab script. Later.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 5th, 2007, 12:03 am 
I discovered this yesterday in the showcase (via google for KDE resizing in Windows XP) and it's almost exactly what I was looking for. Good work! I wish I'd searched for this a year ago!

I notice that the windows don't snap to the edge, like KDE does, so I added that..

Code:
; Easy Window Dragging -- KDE style (requires XP/2k/NT) -- by Jonny
; http://www.autohotkey.com
; This script makes it much easier to move or resize a window: 1) Hold down
; the ALT key and LEFT-click anywhere inside a window to drag it to a new
; location; 2) Hold down ALT and RIGHT-click-drag anywhere inside a window
; to easily resize it; 3) Press ALT twice, but before releasing it the second
; time, left-click to minimize the window under the mouse cursor, right-click
; to maximize it, or middle-click to close it.

; This script was inspired by and built on many like it
; in the forum. Thanks go out to ck, thinkstorm, Chris,
; and aurelian for a job well done.

; Change history:
; December 04, 2007: Window snap-to-edge - just like KDE, but with extra fun! (or @ corz.org ;o)
; November 07, 2006: Optimized resizing code in !RButton, courtesy of bluedawn.
; February 05, 2006: Fixed double-alt (the ~Alt hotkey) to work with latest versions of AHK.

; The Double-Alt modifier is activated by pressing
; Alt twice, much like a double-click. Hold the second
; press down until you click.
;
; The shortcuts:
;  Alt + Left Button  : Drag to move a window.
;  Alt + Right Button : Drag to resize a window.
;  Double-Alt + Left Button   : Minimize a window.
;  Double-Alt + Right Button  : Maximize/Restore a window.
;  Double-Alt + Middle Button : Close a window.
;
; You can optionally release Alt after the first
; click rather than holding it down the whole time.
;
;  Snap-To Edges. by (or .. Tuesday Dec 04, 2007
;
;  I added snap-to for the windows. If their edge comes within ten pixels
;  of your desktop edge, the window snaps to it. Very neat; it's what KDE
;  does. But there's more..
;
;  If you keep mousing after the window snaps, you get a beautiful
;  resizing control which keeps on going. Also you can Alt-right-click
;  any oversized windows and pop them straight back into the desktop.
;  Note: If you are quick enough, you can break the snap when needed.
;  Have fun!
;  ;o)
;


If (A_AhkVersion < "1.0.39.00")
{
    MsgBox,20,,This script may not work properly with your version of AutoHotkey. Continue?
    IfMsgBox,No
    ExitApp
}


; This is the setting that runs smoothest on my
; system. Depending on your video card and cpu
; power, you may want to raise or lower this value.
SetWinDelay,2

CoordMode,Mouse
return

!LButton::
If DoubleAlt
{
    MouseGetPos,,,KDE_id
    ; This message is mostly equivalent to WinMinimize,
    ; but it avoids a bug with PSPad.
    PostMessage,0x112,0xf020,,,ahk_id %KDE_id%
    DoubleAlt := false
    return
}
; Get the initial mouse position and window id, and
; abort if the window is maximized.
MouseGetPos,KDE_X1,KDE_Y1,KDE_id
WinGet,KDE_Win,MinMax,ahk_id %KDE_id%
If KDE_Win
    return
; Get the initial window position.
WinGetPos,KDE_WinX1,KDE_WinY1,,,ahk_id %KDE_id%
Loop
{
    GetKeyState,KDE_Button,LButton,P ; Break if button has been released.
    If KDE_Button = U
        break
    MouseGetPos,KDE_X2,KDE_Y2 ; Get the current mouse position.
    KDE_X2 -= KDE_X1 ; Obtain an offset from the initial mouse position.
    KDE_Y2 -= KDE_Y1
    KDE_WinX2 := (KDE_WinX1 + KDE_X2) ; Apply this offset to the window position.
    KDE_WinY2 := (KDE_WinY1 + KDE_Y2)
    WinMove,ahk_id %KDE_id%,,%KDE_WinX2%,%KDE_WinY2% ; Move the window to the new position.
}
return

!RButton::
If DoubleAlt
{
    MouseGetPos,,,KDE_id
    ; Toggle between maximized and restored state.
    WinGet,KDE_Win,MinMax,ahk_id %KDE_id%
    If KDE_Win
        WinRestore,ahk_id %KDE_id%
    Else
        WinMaximize,ahk_id %KDE_id%
    DoubleAlt := false
    return
}
; Get the initial mouse position and window id, and
; abort if the window is maximized.
MouseGetPos,KDE_X1,KDE_Y1,KDE_id
WinGet,KDE_Win,MinMax,ahk_id %KDE_id%
If KDE_Win
    return
; Get the initial window position and size.
WinGetPos,KDE_WinX1,KDE_WinY1,KDE_WinW,KDE_WinH,ahk_id %KDE_id%
; Define the window region the mouse is currently in.
; The four regions are Up and Left, Up and Right, Down and Left, Down and Right.
If (KDE_X1 < KDE_WinX1 + KDE_WinW / 2)
   KDE_WinLeft := 1
Else
   KDE_WinLeft := -1
If (KDE_Y1 < KDE_WinY1 + KDE_WinH / 2)
   KDE_WinUp := 1
Else
   KDE_WinUp := -1
Loop
{
    GetKeyState,KDE_Button,RButton,P ; Break if button has been released.
    If KDE_Button = U
        break
    MouseGetPos,KDE_X2,KDE_Y2 ; Get the current mouse position.
    ; Get the current window position and size.
    WinGetPos,KDE_WinX1,KDE_WinY1,KDE_WinW,KDE_WinH,ahk_id %KDE_id%
    KDE_X2 -= KDE_X1 ; Obtain an offset from the initial mouse position.
    KDE_Y2 -= KDE_Y1

   ; snap the window to the edge of the screen if closer than 10 pixels..

   if KDE_WinX1 < 10
      KDE_WinX1 := 0

   if KDE_WinY1 < 10
      KDE_WinY1 := 0

   if KDE_WinX1 + KDE_WinW > A_ScreenWidth - 10
      KDE_WinX1 := A_ScreenWidth - KDE_WinW

   if KDE_WinY1 + KDE_WinH > A_ScreenHeight - 10
      KDE_WinY1 := A_ScreenHeight - KDE_WinH

    ; Then, act according to the defined region.
    WinMove,ahk_id %KDE_id%,, KDE_WinX1 + (KDE_WinLeft+1)/2*KDE_X2  ; X of resized window
                            , KDE_WinY1 +   (KDE_WinUp+1)/2*KDE_Y2  ; Y of resized window
                            , KDE_WinW  -     KDE_WinLeft  *KDE_X2  ; W of resized window
                            , KDE_WinH  -       KDE_WinUp  *KDE_Y2  ; H of resized window
    KDE_X1 := (KDE_X2 + KDE_X1) ; Reset the initial position for the next iteration.
    KDE_Y1 := (KDE_Y2 + KDE_Y1)
}
return

; "Alt + MButton" may be simpler, but I
; like an extra measure of security for
; an operation like this.
!MButton::
If DoubleAlt
{
    MouseGetPos,,,KDE_id
    WinClose,ahk_id %KDE_id%
    DoubleAlt := false
    return
}
return

; This detects "double-clicks" of the alt key.
~Alt::
DoubleAlt := A_PriorHotKey = "~Alt" AND A_TimeSincePriorHotkey < 400
Sleep 0
KeyWait Alt  ; This prevents the keyboard's auto-repeat feature from interfering.
return


My first AutoHotKey coding. Fun. Now I just need to figure out how to get it to replace Windows' poor implementation of X-Window raising, and I'm done!

;o)
(or

ps. you other guys.. KDE uses Alt-Click, okay!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 5th, 2007, 12:10 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8647
Location: Salem, MA
cor wrote:
Now I just need to figure out how to get it to replace Windows' poor implementation of X-Window raising, and I'm done!


Do you mean: http://www.autohotkey.com/forum/viewtopic.php?t=22763

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 51 posts ]  Go to page Previous  1, 2, 3, 4  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: lblb, nothing and 12 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