Jump to content

Restrict mouse from certain point on screen


Recommended Posts

Please help me out. I'm trying to make a script that restricts the mouse from moving to a certaing rectangle on the screen, rather than forcing it to stay in a certaing rectangular area on the screen.

EDIT: typo

Edited by dandymcgee

- Dan [Website]

Link to comment
Share on other sites

You can use mousetrap to "trap' it in the region you want allowed. it may be mroe than one reagion which means you'd rapidly set new points.

Ot you can jsut do somthing like-

If MouseGetPos(0)<$SomePoint or MouseGetPos(0)>$SomeOtherPoint then MouseMove($SavePointX,$SavePointY)

Make a some of those in a loop and that should work also.

Link to comment
Share on other sites

Try this: it's a little rough, but it should work for basic uses...
[/s] [s]Global $ExitTL=0, $ExitBR=0
HotKeySet("{ENTER}","NextStep")
While 1
 ToolTip("Put your mouse over the top-left corner and press enter")
 If $ExitTL=1 Then ExitLoop
WEnd
HotKeySet("{ENTER}")
$TLCorner=MouseGetPos()

HotKeySet("{ENTER}","NextStep")
While 1
 ToolTip("Now put your mouse over the bottom-right corner and press enter again")
 If $ExitBR=1 Then ExitLoop
WEnd
HotKeySet("{ENTER}")
$BRCorner=MouseGetPos()
ToolTip("")
MouseMove($BRCorner[0]+1,$BRCorner[1]+1,0)
$LastPos=MouseGetPos()

While 1
 If MouseGetPos(0) > $TLCorner[0] AND MouseGetPos(0) < $BRCorner[0] AND MouseGetPos(1) > $TLCorner[1] AND MouseGetPos(1) < $BRCorner[1] Then
  MouseMove($LastPos[0],$LastPos[1],0)
 Else
  $LastPos=MouseGetPos()
 EndIf
WEnd

Func NextStep()
 If $ExitTL = 0 Then
  $ExitTL = 1
 Else
  $ExitBR = 1
 EndIf
EndFunc

 [/s][s]oÝ÷ Øz)zØb±Ú³Z·*.çß춸¤xGb´â©eÉø º·¢ëa£hr^­#¬¶¼¢h¶§í+¡×°¢¹,ç!²j(¶«z÷§ø­µç!'¦¢·¢jeÆ­yÛhºw^®ËZÜ!Ëey.r¥u©pk+©àzØb²Ç+m¢«uÊz)íë©¥êåyûZÖè¶Ú&®(!µÊ(­Ø§j׬¢»h¥«,¶¦jÇ(f§vX§zö«¦åzÆî´a¢è!¶Øb³²Á«-ç²'¬µú+ué¨ËkjبIã£-÷«­¢+Ù±½°ÀÌØíá¥ÑQ0ôÀ°ÀÌØíá¥Ñ   HôÀ)!½Ñ-åMÐ ÅÕ½Ðíí9QIôÅÕ½Ðì°ÅÕ½Ðí9áÑMÑÀÅÕ½Ðì¤)]¡¥±Ä(Q½½±Q¥À ÅÕ½ÐíAÕÐå½Õȵ½ÕͽÙÈѡѽÀµ±Ð½É¹È¹ÁÉÍ̹ÑÈÅÕ½Ðì¤(%ÀÌØíá¥ÑQ0ôÄQ¡¸á¥Ñ1½½À)]¹)!½Ñ-åMÐ ÅÕ½Ðíí9QIôÅÕ½Ðì¤(ÀÌØíQ1
½É¹Èõ5½ÕÍÑA½Ì ¤()!½Ñ-åMÐ ÅÕ½Ðíí9QIôÅÕ½Ðì°ÅÕ½Ðí9áÑMÑÀÅÕ½Ðì¤)]¡¥±Ä(Q½½±Q¥À ÅÕ½Ðí9½ÜÁÕÐå½Õȵ½ÕͽÙÈÑ¡½Ñѽ´µÉ¥¡Ð½É¹È¹ÁÉÍ̹ÑÈ¥¸ÅÕ½Ðì¤(%ÀÌØíá¥Ñ   HôÄQ¡¸á¥Ñ1½½À)]¹)!½Ñ-åMÐ ÅÕ½Ðíí9QIôÅÕ½Ðì¤(ÀÌØí  I
½É¹Èõ5½ÕÍÑA½Ì ¤)Q½½±Q¥À ÅÕ½ÐìÅÕ½Ðì¤()]¡¥±Ä(%5½ÕÍÑA½Ì À¤ÐìÀÌØíQ1
½É¹ÉlÁt95½ÕÍÑA½Ì À¤±ÐìÀÌØí  I
½É¹ÉlÁt95½ÕÍÑA½Ì ĤÐìÀÌØíQ1
½É¹ÉlÅt95½ÕÍÑA½Ì Ĥ±ÐìÀÌØí  I
½É¹ÉlÅtQ¡¸(%Ì¡5½ÕÍÑA½Ì À¤´ÀÌØíQ1
½É¹ÉlÁt¤±ÐìÌ¡5½ÕÍÑA½Ì À¤´ÀÌØí   I
½É¹ÉlÁt¤9Ì¡5½ÕÍÑA½Ì À¤´ÀÌØíQ1
½É¹ÉlÁt¤±ÐìÌ¡5½ÕÍÑA½Ì Ĥ´ÀÌØíQ1
½É¹ÉlÅt¤9Ì¡5½ÕÍÑA½Ì À¤´ÀÌØíQ1
½É¹ÉlÁt¤±ÐìÌ¡5½ÕÍÑA½Ì Ĥ´ÀÌØí   I
½É¹ÉlÅt¤Q¡¸í±½ÍÍÐѼ±ÐÍ¥(5½ÕÍ5½Ù ÀÌØíQ1
½É¹ÉlÁt±5½ÕÍÑA½Ì Ĥ°À¤(±Í%Ì¡5½ÕÍÑA½Ì Ĥ´ÀÌØíQ1
½É¹ÉlÅt¤±ÐìÌ¡5½ÕÍÑA½Ì Ĥ´ÀÌØí   I
½É¹ÉlÅt¤9Ì¡5½ÕÍÑA½Ì Ĥ´ÀÌØíQ1
½É¹ÉlÅt¤±ÐìÌ¡5½ÕÍÑA½Ì À¤´ÀÌØíQ1
½É¹ÉlÁt¤9Ì¡5½ÕÍÑA½Ì Ĥ´ÀÌØíQ1
½É¹ÉlÅt¤±ÐìÌ¡5½ÕÍÑA½Ì À¤´ÀÌØí   I
½É¹ÉlÁt¤Q¡¸í±½ÍÍÐѼѽÀÍ¥(5½ÕÍ5½Ù¡5½ÕÍÑA½Ì À¤°ÀÌØíQ1
½É¹ÉlÅt°À¤(±Í%Ì¡5½ÕÍÑA½Ì À¤´ÀÌØí   I
½É¹ÉlÁt¤±ÐìÌ¡5½ÕÍÑA½Ì À¤´ÀÌØíQ1
½É¹ÉlÁt¤9Ì¡5½ÕÍÑA½Ì À¤´ÀÌØí    I
½É¹ÉlÁt¤±ÐìÌ¡5½ÕÍÑA½Ì Ĥ´ÀÌØí   I
½É¹ÉlÅt¤9Ì¡5½ÕÍÑA½Ì À¤´ÀÌØí    I
½É¹ÉlÁt¤±ÐìÌ¡5½ÕÍÑA½Ì Ĥ´ÀÌØíQ1
½É¹ÉlÅt¤Q¡¸í±½ÍÍÐѼɥ¡ÐÍ¥(5½ÕÍ5½Ù ÀÌØí   I
½É¹ÉlÁt±5½ÕÍÑA½Ì Ĥ°À¤(±Íí±½ÍÍÐѼ½Ñѽ´Í¥(5½ÕÍ5½Ù¡5½ÕÍÑA½Ì À¤°ÀÌØí  I
½É¹ÉlÅt°À¤(¹%(¹%)]¹()Õ¹9áÑMÑÀ ¤(%ÀÌØíá¥ÑQ0ôÀQ¡¸(ÀÌØíá¥ÑQ0ôÄ(±Í(ÀÌØíá¥Ñ   HôÄ(¹%)¹Õ¹
Edited by james3mg
"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
Link to comment
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
 Share

  • Recently Browsing   0 members

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