No matter what programming language is used, and no matter what framework is used, the underlying mechanism for controlling I/O interfaces as well as UI elements is done at a fundamental level though the operating system's kernel. Due to the fact that the chosen framework is WPF, which is a Windows only C# framework, the solution provided implements a kernel level API call that manipulates the mouse cursor position trough its related kernel API endpoint.
The solution provided in C# within this answer is framework independent, and it utilises the Window Kernel API, by importing the User32.dll, and referencing an API method called SetCursorPos
, which is setting the cursor position as the name implies.
using System;
using System.Runtime.InteropServices;
namespace StackOverflow
{
public class Program
{
// Import the 'User32.dll' Windows OS library to access OS API methods
[DllImport("user32.dll")]
// Reference the 'User32.dll' 'SetCursorPos' method within the 'DllImport' attribute
public static extern bool SetCursorPos(int X, int Y);
public static void Main(string[] args)
{
SetCursorPos(100, 100);
Console.WriteLine("\n\n[ [!!!] Cursor moved to (100, 100) [!!!] ]\n\n");
Console.ReadLine();
}
}
}