Jump to content

Drag Lock


Recommended Posts

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...