05-03-26
Center Mouse Cursor with Hotkey
This Lua script for Rebind hardware moves the mouse cursor to the center of your screen when a hotkey is pressed. It uses the HID and System SDK functions to get screen dimensions and move the cursor.
rebindlua scriptmousecursorcenterhotkeyhid
Question
Create a key that will move the mouse to the center of the current monitor.
Rebind AI
luau
-- rebind: name=Center Mouse
local cfg = UI.Schema({
hotkey = UI.Keybind("F6", { label = "Center Mouse Hotkey" }),
})
Bind(cfg.hotkey, function()
local w, h = System.Screen()
HID.MoveTo(math.floor(w / 2), math.floor(h / 2))
return false
end)This script moves the mouse to the center of your primary monitor when you press the hotkey.
How it works:
System.Screen()gets the primary display width and heightHID.MoveTo(x, y)moves the cursor to an absolute position using relative movements (which is how the Rebind hardware works)math.floor()rounds to whole pixelsreturn falseblocks the key so it doesn't reach your PC
You can customize the hotkey in the UI settings panel.
Learn more: