I found & tweaked a script that does exactly as post's title description, although I'd like to learn/to come with a different approach for arriving to the same result. As long as the cursor is anywhere within selected-window's area, I can move the entire window where-ever (The same action that would normally be done from a window's Title Bar).
As I'm still learning while/loop with combination of keystate and etc. thus avoided said keystate combination via an infinite loop usage where I separately use a "LButton Up" to break-out from infinite loop.
Here is the script,
I'd greatly appreciate if someone could please quickly fix it so that I can avoid using LButton Up
Code: Select all
; .-----------.
; ××××××××××××××××××| VARIABLES |××××××××××××××××××
; '==========='
WindowDragHotkey := 0
; .-----------------------.
; ××××××××××××| SCRIPT VIA SUBROUTINE |××××××××××××
; '======================='
WindowDragOn:
MouseGetPos, MX1, MY1, WinID
WinExist("ahk_id " . WinID)
WinGetPos, WX, WY
While WindowDragHotkey = 1
{
MouseGetPos, MX2, MY2
If (MX1 <> MX2) || (MY1 <> MY2)
{
WX += MX2 - MX1
WY += MY2 - MY1
WinMove, WX, WY
MX1 := MX2
MY1 := MY2
}
}
Return
RETURN
; .---------.
; ×××××××××××××××××××| HOTKEYS |×××××××××××××××××××
; '========='
~LButton & MButton::
WindowDragHotkey = 1
Gosub WindowDragOn
RETURN
~LButton Up::
WindowDragHotkey = 0
RETURN
- LButton & MButton activates it;
- Then I release MButton (but still keep LButton held down)
I'm now into an infinite loop and able to move the window to where-ever/from where-ever within
Releasing said held LButton then breaks out of this infinite loop and ceases "cursor-glued window movement".
But again,
I'd greatly appreciate help on achieving this exact same executed-behavior, but without the use of "LButton Up::"
If someone could please...