Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF: How do I position the mouse cursor in code?

I am implementing the system menu (Restore, Move, Size...) on a borderless window, and I want the mouse cursor to move to the center of the Window when size or move is selected.

Ideally in VB but C# is fine as well.

like image 526
Brad Avatar asked Dec 21 '25 04:12

Brad


1 Answers

You can use the SetCursorPos function, something like:

Declare Function SetCursorPos& Lib "user32" (ByVal p As Point)

'...

dim p as point
p.x = 100
p.y = 200
SetCursorPos p
like image 76
Blindy Avatar answered Dec 22 '25 21:12

Blindy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!