111,096
社区成员




// 获得窗口矩形
[DllImport("user32.dll")]
public static extern int GetWindowRect(IntPtr hWnd, out RECT lpRect);
// 获得客户区矩形
[DllImport("user32.dll")]
public static extern int GetClientRect(IntPtr hWnd, out RECT lpRect);
// 矩形结构
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int Left;//80
public int Top;//450
public double Right;//800
public int Bottom;
}
using System.Runtime.InteropServices;
private static int MOUSEEVENTF_MOVE = 0x0001; //移动鼠标
private static int MOUSEEVENTF_LEFTDOWN = 0x0002; //模拟鼠标左键按下
private static int MOUSEEVENTF_LEFTUP = 0x0004; //模拟鼠标左键抬起
private static int MOUSEEVENTF_RIGHTDOWN = 0x0008; //模拟鼠标右键按下
private static int MOUSEEVENTF_RIGHTUP = 0x0010; //模拟鼠标右键抬起
private static int MOUSEEVENTF_MIDDLEDOWN = 0x0020; //模拟鼠标中键按下
private static int MOUSEEVENTF_MIDDLEUP = 0x0040; //模拟鼠标中键抬起
private static int MOUSEEVENTF_ABSOLUTE = 0x8000; //标示是否采用绝对坐标
[DllImport("user32.dll")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
[System.Runtime.InteropServices.DllImport("user32")]
public static extern int mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
SetForegroundWindow(hwnd_qq);
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, x_qq, y_qq, 0, 0);