I would not recommend to programmatically move a mouse cursor, ever. It can be considered as too intrusive and irritate most users.
However, if you really need to do that, you can do it via the Windows API
SendInput
:
SendInput function (Windows)[
^].
I can be done via P/Invoke. Everything is already done for you:
http://www.pinvoke.net/default.aspx/user32.sendinput[
^].
Actually, P/Invoke greatly compromise your platform compatibility, but you have no choice; controlling of the cursor is not a part of .NET FCL; anyway, see my first paragraph above. :-)
Your code sample, but my feeling is that you a making too big mistakes: using
PictureBox
and using
CreateGraphics
. This is not how graphic rendering is done. But we can discuss it separately; it needs more information of your project.
—SA