C#向窗口的固定坐标出发送鼠标点击信息,什么代码,谢谢?

如题所述

第1个回答  推荐于2018-05-18
///引入命令空间,在这里你可以调用api函数
using System.Runtime.InteropServices;

[DllImport("user32.dll")] ///引入了user32.dll,你就可以使用里面的FindWindow函数
public static extern IntPtr FindWindow(String lpclassName,String lpWindowText);

[DllImport("user32.dll")] ///同上
public static extern int SendMessage(IntPtr hWnd,,int message,IntPtr wParam,IntPtr lParam);

public const int WM_LBUTTONDBLCLK = 515
public const int MK_LBUTTON = 1;
(在电脑中搜索winuser.h,这个文件中包含消息值)
这个消息是左键双击消息

///用于发送消息的方法 x表示横坐标,y表示纵坐标
public void SendMsg(int x,int y){
///获取目标窗口句柄,以下为QQ登录窗口
IntPtr hWnd = FindWindow(null,"QQ2012");
///发送左键双击消息
SendMessage(hWnd,WM_LBUTTONDBLCLK ,(IntPtr)MK_LBUTTON ,(IntPtr)(y * 65536 + x));

望采纳!
}本回答被提问者和网友采纳
第2个回答  2012-03-16
没看明白意思。。

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网