using System.Runtime.InteropServices;
[DllImport("user32.dll")]
static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
const int MOUSEEVENTF_LEFTDOWN = 0x0002;
const int MOUSEEVENTF_LEFTUP = 0x0004;
private void button1_Click(object sender, EventArgs e)
{
Cursor.Position = new Point(this.Location.X + 20, this.Location.Y + 10);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
}
//커서의 현재 위치에서 마우스 좌 클릭 이벤트 발생하는 WIN API 예제 소스 입니다.
'C#' 카테고리의 다른 글
[C#]interface 예제 (0) | 2018.05.24 |
---|---|
[C#]HashTable을 이용한 폼 추가, ShowDialog 예제 (0) | 2018.05.24 |
[C#]PrintWindow를 이용한 화면캡쳐 예제 (0) | 2018.05.18 |
[C#]win api를 이용한 키보드 이벤트(keybd_event) 예제 (0) | 2018.05.18 |
[C#]카운트다운 예제 (0) | 2018.05.16 |