求助C# WinApi移动鼠标的操作
通过API 的Findwindow找了窗口如何实现鼠标相对于找到的这个窗口的左上角定义坐标来自动将鼠标移动目标点(不是相对屏幕的坐标)
--------------------编程问答--------------------
using System;
using System.Runtime.InteropServices;
namespace ConsoleApplication1
{
class Program
{
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetWindowRect(IntPtr hwnd, out RECT lpRect);
[DllImport("user32.dll")]
public static extern bool SetCursorPos(int X, int Y);
public struct RECT
{
public int left, top, right, bottom;
}
static void Main(string[] args)
{
RECT rect;
GetWindowRect(FindWindow("SciCalc", "计算器"), out rect);
SetCursorPos(rect.left, rect.top);
}
}
}
补充:.NET技术 , C#