Center mouse position on 3d view

In region space:

region = context.region
cx = region.width // 2
cy = region.height // 2

In window space:

region = context.region
cx = region.width // 2 + region.x
cy = region.height // 2 + region.y

For moving the cursor in blender, you can use context.window.cursor_warp(x, y).
It takes window coordinates.

You can get the current mouse region coordinates from the event system using

event.mouse_region_x
event.mouse_region_y
1 Like