Jump to content
Sign in to follow this  

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]
    MouseMove($thisPos[0], $thisPos[1], 0)
    $lastPos = $thisPos

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


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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.