Sign in to follow this  
Followers 0
WideBoyDixon

Drag Lock

1 post in this topic

Very quickly, a way of locking down mouse movement to horizontal or vertical only. Use [Win]+Q to cycle horizontal, vertical and no lock. Useful for me when I'm re-arranging items on forms and I want to preserve the top or left coordinate.

HotKeySet("#q", "_ToggleLock")

Global $lockType = 0, $lastPos = MouseGetPos(), $thisPos

While True
    $thisPos = MouseGetPos()
    Switch $lockType
        Case 1 ; Vertical lock
            $thisPos[1] = $lastPos[1]
        Case 2 ; Horizontal lock
            $thisPos[0] = $lastPos[0]
    EndSwitch
    MouseMove($thisPos[0], $thisPos[1], 0)
    $lastPos = $thisPos
    Sleep(10)
WEnd

Func _ToggleLock()
    $lockType = Mod($lockType + 1, 3)
EndFunc   ;==>_ToggleLock

WBD

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0