# Solved: Make cursor move to focused window on focus changed but only if it's not already on it

**URL:** <https://community.folivora.ai/t/solved-make-cursor-move-to-focused-window-on-focus-changed-but-only-if-its-not-already-on-it/45852>\
**Category:** Configuration Help & General Discussion\
**Created:** [December 27, 2025, 12:55am UTC](https://community.folivora.ai/t/solved-make-cursor-move-to-focused-window-on-focus-changed-but-only-if-its-not-already-on-it/45852 "2025-12-27T00:55:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![maddada](https://community.folivora.ai/user_avatar/community.folivora.ai/maddada/32/40019_2.png) [@maddada](https://community.folivora.ai/u/maddada)\
**Post date:** [December 27, 2025, 12:55am UTC](https://community.folivora.ai/t/solved-make-cursor-move-to-focused-window-on-focus-changed-but-only-if-its-not-already-on-it/45852/1 "2025-12-27T00:55:16Z")

</div>

Hey there!

I’m sure this is possible, tried to do it with JS but couldn’t because I don’t see any information in [the BTT JS docs](https://docs.folivora.ai/docs/1106_java_script.html) about getting values about the currently active window and cursor position.

All I need is an if statement to tell me if the mouse is already inside the newly focused window or not.

Thank you for your help as always 🙏🏻

 ![2025-12-27_BetterTouchTool_04-51-29](https://community.folivora.ai/uploads/default/original/3X/5/c/5c09cafa3f675b2896c868464b3f543c3a2ad70d.png)

---

<div class="post-metadata">

**Author:** ![maddada](https://community.folivora.ai/user_avatar/community.folivora.ai/maddada/32/40019_2.png) [@maddada](https://community.folivora.ai/u/maddada)\
**Post date:** [December 28, 2025, 12:46am UTC](https://community.folivora.ai/t/solved-make-cursor-move-to-focused-window-on-focus-changed-but-only-if-its-not-already-on-it/45852/2 "2025-12-28T00:46:36Z")

</div>

Here’s the solution I found.

When the focused window is changed. It checks if the cursor is already inside the focused window, if not then it moves it to the center of that window. (code attached at the bottom of this post)

 ![2025-12-28_BetterTouchTool_04-42-51](https://community.folivora.ai/uploads/default/original/3X/2/5/25fc738346a111ce46e27a4fefdae95ef8ce21c7.jpeg)

Make sure to create a new “Named Trigger” with the following action and call it “CenterMouse”.

 ![2025-12-28_BetterTouchTool_04-44-03](https://community.folivora.ai/uploads/default/original/3X/6/6/66fdde7967e2a9ccebe447f90d92dfd52cf497e6.png)

[moveMouseToFocusedWindow.txt](https://community.folivora.ai/uploads/short-url/tlaXDNEG2g8jbrdF7w47EWJHfg9.txt) (1.4 KB)
