How can I Save & Restore Mouse Position?

How can I re-hover the mouse pointer back to its starting point?

In other words, as the last step in my automation, I want to put the mouse pointer back to the exact same location, within it’s exact same active window (before automation started). I need to hover to this location, WITHOUT clicking on the original window.

  1. Get Active Window activity can save the source window to a variable (e.g. activeWindow).
  2. Activate activity can (element = activeWindow) reactivate the source window.

But, how can I save the mouse cursor position and return the mouse cursor position to this saved position in the activeWindow element?


We can achieve it using System.Windows.Forms.Cursor.Position as the following image.

Main.xaml (5.5 KB)

We can also get Point instance directly, then reuse it.


After copying the sequence to my project, I see the error:
Validation Error Compiler error(s) encountered processing expression “new Point(x,y)”. ‘Point’ is ambiguous, imported from the namespaces or types ‘System.Windows, System.Drawing’.

Any suggestions on how to correct the ambiguous item?


Can you try the following?

new System.Drawing.Point(x,y)


That worked!
Thank you VERY much! I truly appreciate your assistance!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.