[user32.dll] 강제 마우스 컨트롤 ( user32.dll spec )
스트레스 테스트에 활용할법한..

Created with colorer-take5 library. Type 'csharp' 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; using System.Diagnostics; namespace AutoMouseTest { public partial class AutoMouseCursor : Form { //user32.dll 에서 필요한 메서드를 가져��다 :: using System.Runtime.InteropServices; 사용 [DllImport("user32.dll", EntryPoint = "SetCursorPos")] internal extern static Int32 SetCursorPos(Int32 x, Int32 y); [DllImport("user32.dll", EntryPoint = "mouse_event")] internal extern static Int32 mouse_event(uint dwFlags , int dx , int dy , int cButtons , int dwExtraInfo); public AutoMouseCursor() { InitializeComponent(); xposTx.Text = "0"; yposTx.Text = "0"; rbt.CheckStateChanged += new EventHandler(CheckStateChanged); lbt.CheckStateChanged += new EventHandler(CheckStateChanged); linkLabel1.Click += delegate(object sender, EventArgs e) { Console.WriteLine("line"); Process.Start("http://scripter.egloos.com/2539538"); }; } //체크박스 제어 void CheckStateChanged(object sender, EventArgs e) { CheckBox target = sender as CheckBox; if (target.CheckState == CheckState.Checked) { if (target.Name == "rbt") lbt.CheckState = CheckState.Indeterminate; if (target.Name == "lbt") rbt.CheckState = CheckState.Indeterminate; } if (target.CheckState == CheckState.Unchecked) { if (target.Name == "rbt") lbt.CheckState = CheckState.Unchecked; if (target.Name == "lbt") rbt.CheckState = CheckState.Unchecked; } } //실행 private void move_Click(object sender, EventArgs e) { //포지��을 가져�� int xpos = 0; int ypos = 0; Int32.TryParse(xposTx.Text,out xpos); Int32.TryParse(yposTx.Text, out ypos); //이동 SetCursorPos(xpos, ypos); //버튼 클릭 if (rbt.Checked) mouse_event((int)MouseFlags.RIGHTCLICK, xpos, ypos, 0, 0); if (lbt.Checked) mouse_event((int)MouseFlags.LEFTCLICK, xpos, ypos, 0, 0); this.Text = this.Text + " x:" + xpos +" y:" + ypos; } // mouseFlasg 상�� public enum MouseFlags { LEFTDOWN = 0x00000002, LEFTUP = 0x00000004, LEFTCLICK = 0x203, MIDDLEDOWN = 0x00000020, MIDDLEUP = 0x00000040, MOVE = 0x00000001, ABSOLUTE = 0x00008000, RIGHTDOWN = 0x00000008, RIGHTUP = 0x00000010, RIGHTCLICK = 0x206, MOUSE_WHEEL = 0x00000800 } } }'C#' 카테고리의 다른 글
[BackGroundWorkerTEST] Sync , Async , Thread (282) 2010.12.04 [WIN32API] (61) 2010.12.04 [user32.dll] 강제 마우스 컨트롤 ( user32.dll spec ) (63) 2010.12.04 [Thread Invoke / BeginInvoke] invoke 와 begininvoke 의 차이 연구 (74) 2010.12.04 [C# FileDialog] 간단한 Open / Save 파일 다이얼로그 (52) 2010.12.04 [C# Thread]종료시 프로세스 죽이기 (167) 2010.12.04
tags : 2010,
csharp,
DllImport,
MouseControl,
mouse_event,
Process,
SetCursorPos,
TryParse,
user32.dll
C#
2010.12.04 02:24