Moving the Mouse to the Center of the Screen
Translating the mouse to the center of the screen using a script in C#.
Move the cursor to the primary screen center
This top-level C# Action uses the selected input simulator to move the real cursor in primary-monitor desktop coordinates, not window client coordinates.
You can import the ready-made example from here: https://eu.eyeauras.net/share/S202402240046520BBKcR6QKL07
- Create an aura.
- Add
HotkeyIsActiveto it and bind it to a convenient button (this will be our on/off switch, for exampleF3), change the activation type toClick/Hold. - Add a
C# Scriptaction toOn Enter. - Copy and paste the script itself.
- When you press
F3, the cursor will move to the center of the primary screen.
using EyeAuras.Roxy.Api;
using PoeShared.Scaffolding;
var sendInputApi = GetService<ISendInputScriptingApi>();
sendInputApi.TargetWindow = null;
var screenSize = System.Windows.Forms.SystemInformation.PrimaryMonitorSize;
Log.Info($"Primary monitor size: {screenSize}");
sendInputApi.MouseMoveTo(screenSize.Width / 2, screenSize.Height / 2);
F3 moves to the primary monitor center whose dimensions are logged, not the whole virtual-desktop center. TargetWindow = null prevents a target-window activation or coordinate conversion. This synchronous method has no Run token. Resolving the service does not transfer ownership of a system input device.