C#任意位置 模拟鼠标 点击 事件 并获取 鼠标 位置 源码
2012-09-05 18:39
701 查看
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.IO;
using System.Runtime.InteropServices;
using System.Threading;
namespace 模拟鼠标啊啊
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("user32.dll")]
static extern bool SetCursorPos(int x, int y);
[DllImport("user32.dll")]
static extern void mouse_event(MouseEventFlag flags, int dx, int dy, uint data, UIntPtr extraInfo);
[Flags]
enum MouseEventFlag : uint
{
Move = 0x0001,
LeftDown = 0x0002,
LeftUp = 0x0004,
RightDown = 0x0008,
RightUp = 0x0010,
MiddleDown = 0x0020,
MiddleUp = 0x0040,
XDown = 0x0080,
XUp = 0x0100,
Wheel = 0x0800,
VirtualDesk = 0x4000,
Absolute = 0x8000
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
;
Point screenPoint = Control.MousePosition;//获取光标相对屏幕的距离
textBox1.Text = screenPoint.X.ToString();//获得鼠标x轴
textBox2.Text = screenPoint.Y.ToString();//获得鼠标y轴
}
public void xxx(int x,int y) { SetCursorPos(y, x);
mouse_event(MouseEventFlag.LeftDown, 10, 10, 0, UIntPtr.Zero);
mouse_event(MouseEventFlag.LeftUp, 10, 10, 0, UIntPtr.Zero);
}
private void Form1_MouseClick(object sender, MouseEventArgs e)
{
int x =Convert.ToInt32( textBox2.Text);
int y = Convert.ToInt32(textBox1.Text);
this.WindowState = FormWindowState.Minimized;
xxx(x, y);
}
}
}
相关文章推荐
- 点击事件获取鼠标坐标位置(x,y)值
- C# 模拟鼠标点击事件
- jquery 监听鼠标点击事件,任意位置,及是否获得焦点
- js获取鼠标点击事件的相对位置
- js获取鼠标点击事件的相对位置
- C#获取网页中某个元素的位置,并模拟点击
- C#获取鼠标位置,模拟鼠标,模拟键盘(多方转载)
- 【C#】MouseEventArgs事件参数获取鼠标的位置
- C#在窗体中点击任意位置鼠标左键获得该点坐标
- C#实现让鼠标点击任意绝对位置
- 使用C#模拟键盘输入、鼠标移动和点击、设置光标位置及控制应用程序的显示
- 获取winform任意位置点击事件
- C# WinForm窗体任意位置点击事件
- ASP.NET gridview中点击任意行的任意位置选中某行交替效果 变换鼠标手势,获取选定行的指写数据
- MFC 获取picture控件的鼠标点击坐标位置的方法
- C#模拟键盘鼠标事件 SendKeys 的特殊键代码表
- js任意鼠标点击触发事件
- JTable中获取鼠标移动、点击以及内容改变事件
- python爬虫 使用selenium+phontomjs 模拟点击输入 获取东航加载后的源码 机票价格
- JavaScript中几种获取鼠标点击坐标位置的方法