Jump to content

Recommended Posts

Posted

Hello, I've been trying to find out how to lock the Y-axis so that you cannot move up or down past a certain point(dead center of the screen for example), but you can turn side to side just not past that vertical point. I was thinking it could be done using MouseMove but I didn't know how to really do it. Any help will be greatly appreciated.

Thank you.

Nino

Posted

Change the values of $Top and $Bottom to the desired co-ordinates.

$Top = 200
$Bottom = 200

_MouseTrap(0, $Top, @DesktopWidth, $Bottom)

WHile 1
    Sleep(100)
WEnd

Func _MouseTrap($l_left, $l_top, $l_right, $l_bottom)
   $v_Rect = DllStructCreate('int;int;int;int')
   DllStructSetData($v_Rect, 1, $l_left)
   DllStructSetData($v_Rect, 2, $l_top)
   DllStructSetData($v_Rect, 3, $l_right)
   DllStructSetData($v_Rect, 4, $l_bottom)
   $ai_Ret = DllCall('user32.dll', 'int', 'ClipCursor', 'ptr', DllStructGetPtr($v_Rect))
   DllStructDelete($v_Rect)
   Return $ai_Ret[0]
EndFunc

qq

Posted (edited)

Thank you for your help.

Edit. Confused by this error.

$v_Rect = DllStructCreate('int;int;int;int')

$v_Rect = ^ERROR

Error: Unknown Function name.

Edited by Nino
Posted (edited)

Awesome it works! Thanks, but i've tried adding to it, it still runs but my 'macros' or 'binds' or whatever don't work. :)

Edit: The problem is that when I execute the program, it directly locks my Y-axis, I tried to make it so that when I hit LShift it would do that(as you can see), but its not working.

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{LShift}", "MouseTrap")
HotKeySet("{Home}", "Terminate")


$Top = 200
$Bottom = 200

MouseTrap(0, $Top, @DesktopWidth, $Bottom)


WHile 1
    Sleep(1000)
WEnd




Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc


Func MouseTrap($l_left, $l_top, $l_right, $l_bottom)
   $v_Rect = DllStructCreate('int;int;int;int')
   DllStructSetData($v_Rect, 1, $l_left)
   DllStructSetData($v_Rect, 2, $l_top)
   DllStructSetData($v_Rect, 3, $l_right)
   DllStructSetData($v_Rect, 4, $l_bottom)
   $ai_Ret = DllCall('user32.dll', 'int', 'ClipCursor', 'ptr', DllStructGetPtr($v_Rect))
   DllStructDelete($v_Rect)
   Return $ai_Ret[0]
EndFunc


Func Terminate()
    Exit 0
EndFunc

Please tell me what I am doing wrong.

Thanks in advance.

Nino

Edited by Nino
Posted

hay there, um, im not the best for providing others with code :\ but i gave it a shot and here is something that i think your trying to do. I dont know how much your requirements are for the delay but theres something to look at

HotKeySet("{f1}", "lockmouse" ) 
HotKeySet("{f2}", "unlockmouse" ) 
HotKeySet("{f3}", "exitprog" )

Global $yaxis = "400"
Global $loop = 0

while 1
    sleep( 100 )
Wend

Func lockmouse()
    $loop = 1
    while $loop = 1
        $x = MouseGetPos ( 0 )
        MouseMove ( $x, $yaxis , 0 )
    Wend
EndFunc

Func unlockmouse()
    $loop = 0
EndFunc

Func exitprog()
    exit
EndFunc

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
  • Recently Browsing   0 members

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