文档库 最新最全的文档下载
当前位置:文档库 › C#产生鼠标单击事件

C#产生鼠标单击事件

C#产生鼠标单击事件
C#产生鼠标单击事件

using System;

using System.Windows.Forms;

using System.Runtime.InteropServices;

publicclass Form1 : Form

{

[DllImport("user32.dll",CharSet=CharSet.Auto,

CallingConvention=CallingConvention.StdCall)]

publicstaticexternvoid mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons,

uint dwExtraInfo);

privateconstint MOUSEEVENTF_LEFTDOWN = 0x02;

privateconstint MOUSEEVENTF_LEFTUP = 0x04;

privateconstint MOUSEEVENTF_RIGHTDOWN = 0x08;

privateconstint MOUSEEVENTF_RIGHTUP = 0x10;

public Form1()

{

}

publicvoid DoMouseClick()

{

//Call the imported function with the cursor's current position

int X = Cursor.Position.X;

int Y = Cursor.Position.Y;

mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, 0, 0);

}

//...other code needed for the application

}

是调用user32.dll的api,在调用时需要将要模拟点击的位置和左键右键信息传给mouse_event方法。

JS屏蔽大全

JS 屏蔽代码大全 1 >屏蔽功能类 1.1 屏蔽键盘所有键 1.2 屏蔽鼠标右键 在body标签里加上oncontextmenu=self.event.returnvalue=false 或者 function nocontextmenu() { if(document.all) { event.cancelBubble=true; event.returnvalue=false; return false; } } 或者 1.3 屏蔽 Ctrl+N、Shift+F10、F5刷新、退格键