ezzetabi Posted November 10, 2004 Posted November 10, 2004 A UDF... expandcollapse popupAdlibEnable('_MouseTrapSet',50) Sleep(20000) AdlibDisable() Exit ;Locks the mouse in the rectangle of size $iWidth x $iHeight with the upper left ;corner put in $iLeft, $iTop. ; Call this func via AblibEnable as in the example. Func _MouseTrapSet() _MouseTrap(100, 100, 400, 400) EndFunc Func _MouseTrap($iLeft, $iTop, $iWidth, $iHeight) Local $aPos, $iRight, $iBottom $iRight = $iLeft + $iWidth $iBottom = $iTop + $iHeight If $iLeft < 0 Or $iTop < 0 Or $iRight > @DesktopWidth Or $iBottom > @DesktopHeight Then SetError (1) Return 0 EndIf $aPos = MouseGetPos() Select Case $aPos[0] > $iRight MouseMove($iLeft, $aPos[1], 0) Case $aPos[0] < $iLeft MouseMove($iRight, $aPos[1], 0) Case $aPos[1] > $iBottom MouseMove($aPos[0], $iTop, 0) Case $aPos[1] < $iTop MouseMove($aPos[0], $iBottom, 0) EndSelect EndFunc ;==>_MouseTrap
this-is-me Posted November 11, 2004 Posted November 11, 2004 You could have some fun with this making a mouse wrap script: _MouseTrap(2, 2, @DesktopWidth - 4, @DesktopHeight - 4) When your cursor goes all the way to the left of the screen, it ends up at the right side. Same for all corners. Who else would I be?
ezzetabi Posted November 11, 2004 Author Posted November 11, 2004 The new (still unreleased) version of Run! have this feature. ATM I am using this. It is confortating, but confusing.
Christopher Blue Posted November 24, 2004 Posted November 24, 2004 (edited) When I needed to make a mouse trap for windowed Warcraft 3 I found that the Windows.h "ClipCursor" function fit the situation like a glove. However it required a RECT structure as one of the parameters which AutoIt cannot provide (yet!). Hence I wrote two tiny C++ programs: one to trap the mouse and one to untrap it and an AutoIt script to interface with them. It wouldn't take much to simply pass an argument to one program that would do both but I was in a hurry. If you are interested, the thread is here. Edited November 24, 2004 by Christopher Blue
coolness Posted April 5, 2006 Posted April 5, 2006 works fine, up untill the point that I left click the mouse, and refresh. which terminates the script.
GaryFrost Posted April 5, 2006 Posted April 5, 2006 When I needed to make a mouse trap for windowed Warcraft 3 I found that the Windows.h "ClipCursor" function fit the situation like a glove. However it required a RECT structure as one of the parameters which AutoIt cannot provide (yet!). Hence I wrote two tiny C++ programs: one to trap the mouse and one to untrap it and an AutoIt script to interface with them. It wouldn't take much to simply pass an argument to one program that would do both but I was in a hurry. If you are interested, the thread is here._MouseTrap in the beta include Misc.au3 uses the clipcursor SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now