Getting and setting the mouse position in WPF
Method One: WPF method
Point P = mouse.getposition
(e.source as FrameworkElement);
Point P = (E.source as FrameworkElement). Pointtoscreen (PP);
Method Two: API method
<summary>///Set Mouse coordinates///</summary>///<param name= "x" > Horizontal coordinate </p
aram>///<param name= "y" > Ordinate </param> [DllImport ("User32")]
public extern static void Setcursorpos (int x, int y);
Public struct Point {public int X;
public int Y; public point (int x, int y) {this.
x = x; This.
y = y; }///<summary>///Gets the coordinates of the mouse///</summary>///
<param name= "Lppoint" > Address parameters, coordinate point type </param>///<returns> get successful return True </returns> [DllImport ("user32.dll", CharSet = CharSet.Auto)] public static extern bool GetCursorPos (out Point pt)
; private void Window_mousemove (object sender, MouseEventArgs e) {point P = new POINT (); if (GetCursorPos (out P))//api method {Txtstat.text = string.
Format ("x:{0} Y:{1}", p.x, P.Y); }
}