# Is there mouse locking in processing?

**URL:** <https://discourse.processing.org/t/is-there-mouse-locking-in-processing/1633>\
**Category:** Coding Questions\
**Created:** [July 9, 2018, 4:55pm UTC](https://discourse.processing.org/t/is-there-mouse-locking-in-processing/1633 "2018-07-09T16:55:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![codingking03](https://avatars.discourse-cdn.com/v4/letter/c/3ec8ea/32.png) [@codingking03](https://discourse.processing.org/u/codingking03)\
**Post date:** [July 9, 2018, 4:55pm UTC](https://discourse.processing.org/t/is-there-mouse-locking-in-processing/1633/1 "2018-07-09T16:55:10Z")

</div>

Is there a way to not necessarily lock the mouse in the middle of the screen, but rather make sure that it stays within a small box in the middle and when it hits the edge will just go on the other side? And of course it only can do this while a boolean is said to be true. I checked old forums and I couldn’t find anything on it, also there are no libraries i could find either.

---

<div class="post-metadata">

**Author:** ![codingking03](https://avatars.discourse-cdn.com/v4/letter/c/3ec8ea/32.png) [@codingking03](https://discourse.processing.org/u/codingking03)\
**Post date:** [July 9, 2018, 4:55pm UTC](https://discourse.processing.org/t/is-there-mouse-locking-in-processing/1633/2 "2018-07-09T16:55:44Z")

</div>

I cant lock it in the middle because I wouldn’t be able to calculate mouse movement… or would I? please help.

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [July 9, 2018, 4:56pm UTC](https://discourse.processing.org/t/is-there-mouse-locking-in-processing/1633/3 "2018-07-09T16:56:32Z")

</div>

Use the Robot class. You should be able to find some relevant code in the old forum.

Kf

---

<div class="post-metadata">

**Author:** ![neilcsmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/neilcsmith/32/144_2.png) [@neilcsmith](https://discourse.processing.org/u/neilcsmith)\
**Post date:** [July 9, 2018, 4:57pm UTC](https://discourse.processing.org/t/is-there-mouse-locking-in-processing/1633/4 "2018-07-09T16:57:23Z")

</div>

Or JOGL classes. Depends what renderer you’re using. Just found this searching on JOGL - [http://twicetwo.com/blog/processing/2016/03/01/processing-locking-the-mouse.html](http://twicetwo.com/blog/processing/2016/03/01/processing-locking-the-mouse.html)

---

<div class="post-metadata">

**Author:** ![codingking03](https://avatars.discourse-cdn.com/v4/letter/c/3ec8ea/32.png) [@codingking03](https://discourse.processing.org/u/codingking03)\
**Post date:** [July 9, 2018, 4:58pm UTC](https://discourse.processing.org/t/is-there-mouse-locking-in-processing/1633/5 "2018-07-09T16:58:27Z")

</div>

@kfrajer can you give me a link?  
@neilcsmith Im using P3D

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [July 9, 2018, 5:00pm UTC](https://discourse.processing.org/t/is-there-mouse-locking-in-processing/1633/6 "2018-07-09T17:00:25Z")

</div>

- [https://Forum.Processing.org/two/discussions/tagged?Tag=robot.mousemove()](https://Forum.Processing.org/two/discussions/tagged?Tag=robot.mousemove%28%29)
- [https://Docs.Oracle.com/javase/8/docs/api/java/awt/Robot.html#mouseMove-int-int-](https://Docs.Oracle.com/javase/8/docs/api/java/awt/Robot.html#mouseMove-int-int-)
