c# 调用API mouse_event 模拟鼠标事件
2011-02-12 21:56
731 查看
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
const int MOUSEEVENTF_MOVE = 0x0001; // 移动鼠标
const int MOUSEEVENTF_LEFTDOWN = 0x0002; //模拟鼠标左键按下
const int MOUSEEVENTF_LEFTUP = 0x0004; //模拟鼠标左键抬起
const int MOUSEEVENTF_RIGHTDOWN = 0x0008; //模拟鼠标右键按下
const int MOUSEEVENTF_RIGHTUP = 0x0010; //模拟鼠标右键抬起
const int MOUSEEVENTF_MIDDLEDOWN = 0x0020;// 模拟鼠标中键按下
const int MOUSEEVENTF_MIDDLEUP = 0x0040;// 模拟鼠标中键抬起
const int MOUSEEVENTF_ABSOLUTE = 0x8000; //标示是否采用绝对坐标
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
mouse_event(MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_ABSOLUTE, 500, 400, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP , 500, 400, 0, 0);
}
[DllImport("user32", EntryPoint = "mouse_event")]
private static extern int mouse_event(
int dwFlags,// 下表中标志之一或它们的组合
int dx,
int dy, //指定x,y方向的绝对位置或相对位置
int cButtons,//没有使用
int dwExtraInfo//没有使用
);
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
const int MOUSEEVENTF_MOVE = 0x0001; // 移动鼠标
const int MOUSEEVENTF_LEFTDOWN = 0x0002; //模拟鼠标左键按下
const int MOUSEEVENTF_LEFTUP = 0x0004; //模拟鼠标左键抬起
const int MOUSEEVENTF_RIGHTDOWN = 0x0008; //模拟鼠标右键按下
const int MOUSEEVENTF_RIGHTUP = 0x0010; //模拟鼠标右键抬起
const int MOUSEEVENTF_MIDDLEDOWN = 0x0020;// 模拟鼠标中键按下
const int MOUSEEVENTF_MIDDLEUP = 0x0040;// 模拟鼠标中键抬起
const int MOUSEEVENTF_ABSOLUTE = 0x8000; //标示是否采用绝对坐标
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
mouse_event(MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_ABSOLUTE, 500, 400, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP , 500, 400, 0, 0);
}
[DllImport("user32", EntryPoint = "mouse_event")]
private static extern int mouse_event(
int dwFlags,// 下表中标志之一或它们的组合
int dx,
int dy, //指定x,y方向的绝对位置或相对位置
int cButtons,//没有使用
int dwExtraInfo//没有使用
);
}
}
相关文章推荐
- c# 调用API mouse_event 模拟鼠标事件
- C#调用API:mouse_event 模拟鼠标事件
- C# 调用API keybd_event 模拟键盘事件
- C#计时器;控件移动;获取鼠标坐标;事件调用事件;
- C#模拟键盘鼠标事件
- 使用API函数mouse_event可以模拟鼠标事件
- C#模拟键盘鼠标事件 SendKeys 的特殊键代码表
- C#模拟键盘鼠标事件 SendKeys 的特殊键代码表
- C#任意位置 模拟鼠标 点击 事件 并获取 鼠标 位置 源码
- SendInput和mouse_event模拟鼠标点击事件问题解决
- keybd_event,mouse_event 模拟产生键盘事件、鼠标事件的使用
- C#模拟键盘鼠标事件
- (转)C#模拟键盘鼠标事件
- C#模拟键盘鼠标事件
- 使用mouse_event模拟鼠标事件时,程序窗口失去焦点就失效
- C#中实现模拟鼠标事件
- C#模拟键盘鼠标事件 SendKeys 的特殊键代码表
- C# 模拟鼠标(mouse_event)
- C# 模拟鼠标事件
- C#中实现模拟鼠标事件