【文件属性】:
文件名称:C#自动点击按钮
文件大小:38KB
文件格式:RAR
更新时间:2016-12-25 01:35:31
自动点击按钮
public int X;
public int Y;
}
public enum MouseEventFlags
{
Move = 0x0001,
LeftDown = 0x0002,
LeftUp = 0x0004,
RightDown = 0x0008,
RightUp = 0x0010,
MiddleDown = 0x0020,
MiddleUp = 0x0040,
Wheel = 0x0800,
Absolute = 0x8000
}
private void AutoClick(int x, int y)
{
POINT p = new POINT();
GetCursorPos(out p);
try
{
SetCursorPos(x, y);
mouse_event((int)(MouseEventFlags.LeftDown | MouseEventFlags.Absolute), 0, 0, 0, IntPtr.Zero);
mouse_event((int)(MouseEventFlags.LeftUp | MouseEventFlags.Absolute), 0, 0, 0, IntPtr.Zero);
}
finally
{
SetCursorPos(p.X, p.Y);
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Point p = this.button2.PointToScreen(button2.Location);
AutoClick(p.X , p.Y );
}
private void button2_MouseClick(object sender, MouseEventArgs e)
{
button2.Text = "哈哈,点击了!!!!!!!";
}
【文件预览】:
WindowsFormsApplication4
----WindowsFormsApplication4()
--------WindowsFormsApplication4.csproj(4KB)
--------Form1.cs(2KB)
--------Program.cs(505B)
--------Form1.resx(6KB)
--------Properties()
--------Form1.Designer.cs(3KB)
--------obj()
--------bin()
----WindowsFormsApplication4.suo(18KB)
----WindowsFormsApplication4.sln(914B)