Path: utzoo!censor!geac!torsqnt!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!rutgers!psuvax1!xavier!jackiw From: jackiw@cs.swarthmore.edu (Nick Jackiw) Newsgroups: comp.sys.mac.programmer Subject: Re: How do you set the mouse position? Message-ID: Date: 26 Feb 90 14:42:15 GMT References: <4081@hub.UUCP> Sender: news@xavier.swarthmore.edu (USENET News System) Reply-To: jackiw@cs.swarthmore.edu (Nick Jackiw) Organization: Visual Geometry Project, Swarthmore College, PA Lines: 53 6500stom@hub.UUCP (Josh Pritikin) writes: > I need to be able to set the position of the mouse for a game that > I'm writting. Actually, limiting the mouse movement to a rectangle > on the screen would work as well but I remember seeing a lot of > letters in MacTutor argueing the point. Does anyone have the code > to put the mouse somewhere the "correct way" or limit the mouse to > a rect? > No. You bad, bad rabbit. The incorrect way, in that it violates all sorts of interface rules (like: the user decides where the mouse goes) and compatibility guidelines (like: don't access undocumented low-memory globals) was discussed here quite some time ago. Try: procedure SetMouse(where:point); {Thanks to Chris Muir, pacbell!well!cbm, for posting the original version of this.} var LowGlob:integer; LowMem:ptr; PointPtr:^point; finalTicks:longint; const MBState=$172; MTemp=$828; RawMouse=$82C; Mouse=$830; CrsrNew=$8ce; begin LocalToGlobal(where); LowMem:=pointer(RawMouse); PointPtr:=@LowMem^; PointPtr^:=where; LowMem:=pointer(MTemp); PointPtr:=@LowMem^; PointPtr^:=where; LowMem:=pointer(CrsrNew); LowMem^:=$ffff; Delay(5,finalTicks) end; If you're after user friendliness, you might want to check that your app is running on an architecture (hardware+System Version) with which you've tested this works, and if not, warn them of a possible incompatibility before letting them start the game. -Nick jackiw@cs.swarthmore.edu -- "'I have seen too often your filthy teeth snap with rage and your august countenance, covered with the fungus of time, blush like a flaming coal because of some microscopic futility that man had commited, to be able to pause longer before the signpost of that silly hypothesis.'" -Maldoror