DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Request. Add feature to the free program  (Read 27,665 times)

plander

  • Participant
  • Joined in 2012
  • *
  • Posts: 8
Request. Add feature to the free program
« on: July 17, 2012, 05:35 PM »
Hi. I use a program, called AltDrag, this program very good, but haven't 1 useful thing - i can't drag windows by pressing only middle mouse button, they can drag windows by combinations alt or ctrl + mouse button, but drag windows by only middle button, without alt or ctrl this program can't. I talk with author, but he say that he haven't time to add this feature and say that i can add by myself, it's free source code, but i don't know coding, but want this feature very much :(

Pls someone can add this feature to this program? or in irc guys give me some script, but he can't drag only by middle mouse button to, may be u can edit this script or add feature to the program?

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: Request. Add feature to the free program
« Reply #1 on: July 17, 2012, 06:05 PM »
or in irc guys give me some script, but he can't drag only by middle mouse button to, may be u can edit this script or add feature to the program?

Hi, plander, and welcome to DonationCoder.  Here is a modified version of the AHK script that should do what you requested:

Code: (autohotkey)
~MButton::
CoordMode, Mouse  ; Switch to screen/absolute coordinates.
MouseGetPos, EWD_MouseStartX, EWD_MouseStartY, EWD_MouseWin
WinGetPos, EWD_OriginalPosX, EWD_OriginalPosY,,, ahk_id %EWD_MouseWin%
WinGet, EWD_WinState, MinMax, ahk_id %EWD_MouseWin% 
if EWD_WinState = 0  ; Only if the window isn't maximized 
    SetTimer, EWD_WatchMouse, 10 ; Track the mouse as the user drags it.
return

EWD_WatchMouse:
GetKeyState, EWD_LButtonState, MButton, P
if EWD_LButtonState = U  ; Button has been released, so drag is complete.
{
    SetTimer, EWD_WatchMouse, off
    return
}
GetKeyState, EWD_EscapeState, Escape, P
if EWD_EscapeState = D  ; Escape has been pressed, so drag is cancelled.
{
    SetTimer, EWD_WatchMouse, off
    WinMove, ahk_id %EWD_MouseWin%,, %EWD_OriginalPosX%, %EWD_OriginalPosY%
    return
}
; Otherwise, reposition the window to match the change in mouse coordinates
; caused by the user having dragged the mouse:
CoordMode, Mouse
MouseGetPos, EWD_MouseX, EWD_MouseY
WinGetPos, EWD_WinX, EWD_WinY,,, ahk_id %EWD_MouseWin%
SetWinDelay, -1   ; Makes the below move faster/smoother.
WinMove, ahk_id %EWD_MouseWin%,, EWD_WinX + EWD_MouseX - EWD_MouseStartX, EWD_WinY + EWD_MouseY - EWD_MouseStartY
EWD_MouseStartX := EWD_MouseX  ; Update for the next timer-call to this subroutine.
EWD_MouseStartY := EWD_MouseY
return

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: Request. Add feature to the free program
« Reply #2 on: July 17, 2012, 06:12 PM »
Hi, plander, and welcome to DonationCoder.  Here is a modified version of the AHK script that should do what you requested:
I believe what plander is asking for is a program that works both with mbutton and with alt. From what I understand, you are suggesting that he runs both the program you posted and the original AHK version, right?

AndyM

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 616
Re: Request. Add feature to the free program
« Reply #3 on: July 17, 2012, 06:35 PM »
Move Inactive Window by Skrommel

http://www.donationcoder.com/Software/Skrommel/#MoveInactiveWin

Hold down the Alt key and LeftClick drag any non-focused window without giving that window focus.  That's the original purpose of the script, but Alt-drag works on the active window also.

You could check out the code to change or add other hotkey combinations.

plander

  • Participant
  • Joined in 2012
  • *
  • Posts: 8
Re: Request. Add feature to the free program
« Reply #4 on: July 17, 2012, 07:14 PM »
i want hold only middle button and drag, not alt + left mouse button, not alt + middle mouse button, only middle

plander

  • Participant
  • Joined in 2012
  • *
  • Posts: 8
Re: Request. Add feature to the free program
« Reply #5 on: July 17, 2012, 07:18 PM »
skwire thank u for the script, it's work, thank you, but it not work for full opened windows and this script can't do many good things that can do altdrag program, may be u can add this feature to the program? :(
« Last Edit: July 17, 2012, 07:44 PM by plander »

AndyM

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 616
Re: Request. Add feature to the free program
« Reply #6 on: July 17, 2012, 07:20 PM »
then try skwire's script

plander

  • Participant
  • Joined in 2012
  • *
  • Posts: 8
Re: Request. Add feature to the free program
« Reply #7 on: July 17, 2012, 07:26 PM »
and what about edit altdrag program? coz program very useful and functional and i want very much use it with middle button
« Last Edit: July 17, 2012, 07:38 PM by plander »

tomos

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 11,970
    • Gathering Badge
    • Participated in NANY Challenge Once
Re: Request. Add feature to the free program
« Reply #8 on: July 17, 2012, 09:10 PM »
and what about edit altdrag program?

have you asked the author of AltDrag?
Tom

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: Request. Add feature to the free program
« Reply #9 on: July 17, 2012, 10:28 PM »
have you asked the author of AltDrag?
I talk with author, but he say that he haven't time to add this feature and say that i can add by myself, it's free source code, but i don't know coding, but want this feature very much
yep :P

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: Request. Add feature to the free program
« Reply #10 on: July 17, 2012, 10:47 PM »
AltDrag has a window resize similar to linux: when you press Alt and drag close to the corner, you can resize that window in that direction.
I'm pretty sure I've seen something like that somewhere. Probably it's one of these two (most likely the first one):
http://www.autohotkey.com/docs/scripts/EasyWindowDrag_(KDE).htm
http://www.enovatic.org/products/niftywindows/onlinedemo/

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: Request. Add feature to the free program
« Reply #11 on: July 17, 2012, 10:49 PM »
Also, another option: plander, why don't you run the script skrommel posted and altdrag? They complement each other and could solve your problem.

plander

  • Participant
  • Joined in 2012
  • *
  • Posts: 8
Re: Request. Add feature to the free program
« Reply #12 on: July 18, 2012, 05:39 AM »
jgpaiva i run script and altdrag, but they do not interact together , coz when i drag windows by middle mouse button the don't resize and nothing happend (they just moving by script), (when i use alt drag commands) windows resize only when i press alt + drag window, but i want only press middle button and drag and resize. They work separately, not together, this is a problem.

and thank you for the NiftyWindows program, very interesting, but steel haven't drag by middle button and hotkeys in opera not work when run NiftyWindows :(
« Last Edit: July 18, 2012, 08:00 AM by plander »

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: Request. Add feature to the free program
« Reply #13 on: July 18, 2012, 03:25 PM »
I see.
I modified the easywindowdrag script to include the resizing stuff.
See below:
Code
; 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. Modified by jgpaiva

; Change history:
; 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.
; February 05, 2006: removed alt stuff, changed for middlebutton

; 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.

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

MButton::
; 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.
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

centerX := KDE_X1 > KDE_WinX1 + KDE_WinW / 3 AND KDE_X1 < KDE_WinX1 + 2*KDE_WinW /3

centerY := KDE_Y1 > KDE_WinY1 + KDE_WinH / 3 AND KDE_Y1 < KDE_WinY1 + 2*KDE_WinH /3


Loop
{
    GetKeyState,KDE_Button,MButton,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.
    if (centerX AND centerY)
      WinMove,ahk_id %KDE_id%,, KDE_WinX1 + KDE_X2  ; X of resized window
                              , KDE_WinY1 + KDE_Y2  ; Y of resized window
                              , KDE_WinW ; W of resized window
                              , KDE_WinH ; H of resized window
    else
        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
DISCLAIMER: I do *not* have a computer to test this code on, so it may very well not work. If any bananas explode when using this program, I claim no responsibility :P
« Last Edit: July 19, 2012, 03:58 PM by jgpaiva »

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: Request. Add feature to the free program
« Reply #14 on: July 19, 2012, 03:58 PM »
Ok, I've updated the above post to include code that actually has been tested and works! :P

plander

  • Participant
  • Joined in 2012
  • *
  • Posts: 8
Re: Request. Add feature to the free program
« Reply #15 on: July 19, 2012, 06:07 PM »
jgpaiva yea it's work, but not so cool like altdrag or other functional programs  :(

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: Request. Add feature to the free program
« Reply #16 on: July 19, 2012, 06:09 PM »
jgpaiva yea it's work, but not so cool like altdrag or other functional programs  :(
What are you missing?

plander

  • Participant
  • Joined in 2012
  • *
  • Posts: 8
Re: Request. Add feature to the free program
« Reply #17 on: July 24, 2012, 08:36 PM »
Is it so hard to add middle button feature to altdrag ?

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: Request. Add feature to the free program
« Reply #18 on: July 24, 2012, 11:46 PM »
Given that altdrag is written in C, yes. It would be a considerable amount of work to understand how the program is implemented, and then I'd have to learn how to create the hooks for the middle button in C (which I have zero previous experience). I'm sorry, but if that's what you need, I really can't help anymore :(

plander

  • Participant
  • Joined in 2012
  • *
  • Posts: 8
Re: Request. Add feature to the free program
« Reply #19 on: July 25, 2012, 06:05 AM »
:( and noone else can't do that?

AndyM

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 616
Re: Request. Add feature to the free program
« Reply #20 on: July 25, 2012, 02:34 PM »
I've assigned things to the middle button using AutoHotkey.  It can be a little flakey so I only kept the things that worked.

Might be worth a try so you could keep AltDrag and assign either Alt-Left or Alt-Middle to MiddleButtonDown.  Can't see how you could assign both to MiddleButtonDown, and Alt-Middle might be flakey.  Assigning  Alt-Left ButtonDown to MiddleButtonDown would be worth a try if that's the key combo you want to fire when you MiddleClickDrag.

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: Request. Add feature to the free program
« Reply #21 on: July 30, 2012, 08:13 PM »
Here's an alternative to AltDrag that allows you to set the middle mouse button to resize windows:

http://www.deskex.com/AltMove/index.asp

Original address: https://www.donationcoder.com/forum/index.php?topic=31665.0