如果我知道X座標和Y座標,是否有一個Windows API或.NET中的一些技術,我可以使用它來使鼠標指針移動到該點?你可以強制鼠標移動嗎?
我知道必須有東西,因爲有些工具看起來像是在跳鼠標。但我不知道這些API是否可以通過.Net輕鬆訪問。 有嗎?
請假定WPF,.Net和Windows(當然)。
解決方案
public Window1()
{
InitializeComponent();
NativeMethods.SetCursorPos(300, 300);
}
public partial class NativeMethods
{
[System.Runtime.InteropServices.DllImportAttribute("user32.dll",
EntryPoint = "SetCursorPos")]
[return: System.Runtime.InteropServices.MarshalAsAttribute
(System.Runtime.InteropServices.UnmanagedType.Bool)]
public static extern bool SetCursorPos(int X, int Y);
}