• Program to edit mouse movment
    7 replies, posted
I was wondering if anyone had any simple .exe files which allow you to disable vertical mouse movement at the press of a button, otherwise if anyone could tell me how to make one it would be much apreiciated (I'm only good at codeing in turbo-pascal for some reason my tutor made me start with it as a first programing language)
For Windows, you can lock the cursor using the ClipCursor function of the Windows API. If you wanted to lock it at the current mouse Y position, you could do this (example in the C(99) programming language): [cpp] POINT curPos; GetCursorPos(&curPos); RECT confinedArea; GetClipCursor(&confinedArea); //Get the currently clipped area, usually your entire screen confinedArea.top = curPos.y, confinedArea.bottom = curPos.y; //Set the top and bottom values to the mouse Y position ClipCursor(&confinedArea); //use the newly defined area as the mouse clip [/cpp] To revert the changes, call ClipCursor with NULL to reset the clip to the entire screen: [cpp] ClipCursor(NULL); //reset mouse clip [/cpp] As for "at the press of a button", that depends on what kind of input you want. If you want a global key hook, that's a fair bit more complicated. As for using Windows API functions in Turbo-Pascal; I can't help you with that.
I know .net has System.Windows.Forms.Cursor, which makes it stupidly easy to do what you want. [editline]11:16PM[/editline] Oh wait, it disables itself if the window loses focus. Do what ja_cop said.
Wouldn't it be useful in 99.99% of cases for it to disable when the window loses focus? or is the problem that it doesn't re-enable when it regains focus?
[QUOTE=<ToD> Aaron;21934691]Wouldn't it be useful in 99.99% of cases for it to disable when the window loses focus? or is the problem that it doesn't re-enable when it regains focus?[/QUOTE] He might not have a window of his own, this could be for other windows running in the same environment.
Sounds kinda like he's trying to make a script-kiddie type virus then? I can't think of any other need for locking the mouse movements. Wouldn't you usually do that if you were using only keyboard controls for movement and the like and using the mouse only for an aiming of sort? That way you could make sure the user didn't accidentally click out of the window?
[QUOTE=<ToD> Aaron;21934779]Sounds kinda like he's trying to make a script-kiddie type virus then? I can't think of any other need for locking the mouse movements. Wouldn't you usually do that if you were using only keyboard controls for movement and the like and using the mouse only for an aiming of sort? That way you could make sure the user didn't accidentally click out of the window?[/QUOTE] No don’t worry no viruses or any thing vaguely malicious [editline]01:59PM[/editline] [QUOTE=jA_cOp;21926942]For Windows, you can lock the cursor using the ClipCursor function of the Windows API. If you wanted to lock it at the current mouse Y position, you could do this (example in the C(99) programming language): [cpp] POINT curPos; GetCursorPos(&curPos); RECT confinedArea; GetClipCursor(&confinedArea); //Get the currently clipped area, usually your entire screen confinedArea.top = curPos.y, confinedArea.bottom = curPos.y; //Set the top and bottom values to the mouse Y position ClipCursor(&confinedArea); //use the newly defined area as the mouse clip [/cpp] To revert the changes, call ClipCursor with NULL to reset the clip to the entire screen: [cpp] ClipCursor(NULL); //reset mouse clip [/cpp] As for "at the press of a button", that depends on what kind of input you want. If you want a global key hook, that's a fair bit more complicated. As for using Windows API functions in Turbo-Pascal; I can't help you with that.[/QUOTE] Thanks alot (and I dont think it's possible in T-Pascal anyway)
Indeed, you can't call API functions from a Turbo Pascal application. [url]http://www.delphipages.com/forum/showthread.php?t=9533[/url] You can, however, call them from a [url=http://www.freepascal.org]Free Pascal[/url] application. [url]http://wiki.freepascal.org/Windows_API_units[/url]
Sorry, you need to Log In to post a reply to this thread.