# Run script on any mouse click

**URL:** <https://forum.inductiveautomation.com/t/run-script-on-any-mouse-click/26963>\
**Category:** Ignition\
**Created:** [July 29, 2019, 6:16pm UTC](https://forum.inductiveautomation.com/t/run-script-on-any-mouse-click/26963 "2019-07-29T18:16:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kwj](https://avatars.discourse-cdn.com/v4/letter/k/838e76/32.png) [@kwj](https://forum.inductiveautomation.com/u/kwj)\
**Post date:** [July 29, 2019, 6:16pm UTC](https://forum.inductiveautomation.com/t/run-script-on-any-mouse-click/26963/1 "2019-07-29T18:16:25Z")

</div>

This is either an odd question or a bad idea or very obvious because I can’t find anything on the forum related to it. Is there a way to run a script on any mouse click in the client? I thought I could make a keystroke client script for it, but don’t see how to do that on just the left click.

I have a popup that I would like to close on any mouse click outside of it. I can use mouseexited() on the popup, but I don’t know if the user’s mouse will ever be in it.

---

<div class="post-metadata">

**Author:** ![kwj](https://avatars.discourse-cdn.com/v4/letter/k/838e76/32.png) [@kwj](https://forum.inductiveautomation.com/u/kwj)\
**Post date:** [July 29, 2019, 6:28pm UTC](https://forum.inductiveautomation.com/t/run-script-on-any-mouse-click/26963/3 "2019-07-29T18:28:57Z")

</div>

Thanks, should have said - this is in 7.9

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 29, 2019, 6:59pm UTC](https://forum.inductiveautomation.com/t/run-script-on-any-mouse-click/26963/4 "2019-07-29T18:59:18Z")

</div>

Unfortunately, no. Java Swing’s event model has input events consumed at the innermost component that listens for them, so there’s no reliable way to capture that click (it’ll be consumed by whatever is clicked). You might find what you need among the various lostFocus events.

---

<div class="post-metadata">

**Author:** ![BIBIN\_K\_BABU](https://avatars.discourse-cdn.com/v4/letter/b/aeb1de/32.png) [@BIBIN\_K\_BABU](https://forum.inductiveautomation.com/u/BIBIN_K_BABU)\
**Post date:** [February 16, 2022, 11:12am UTC](https://forum.inductiveautomation.com/t/run-script-on-any-mouse-click/26963/5 "2022-02-16T11:12:35Z")

</div>

Is there any way to run script for any mouse click inside a vision window with the latest release?My requirement is to track the number of clicks by each user.

Thanks
