Languages/C#2010. 12. 7. 11:47

Win32 API를 사용해

해당 위치에 마우스 다운, 업 이벤트를 발생하는 예제입니다.

 

 using System.Runtime.InteropServices;

 

 class Win32API

 {

     public const uint WM_LBUTTONDOWN = 0x00000002;

     public const uint WM_LBUTTONUP = 0x00000004;

 

     [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]

     public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, int dwExtraInfo);

 

     [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]

     public static extern int SetCursorPos(int x, int y);

 }

 

 ex )

       Win32API.SetCursorPos(x, y);

       Win32API.mouse_event(Win32API.WM_LBUTTONDOWN, 0, 0, 0, 0);

       Win32API.mouse_event(Win32API.WM_LBUTTONUP, 0, 0, 0, 0);

 

 

'Languages > C#' 카테고리의 다른 글

[ C# ] Object To Byte, Byte To Byte  (0) 2013.02.26
[ C# ] Struct To Byte, Byte To Struct  (0) 2012.08.17
[ C# ] C# FTP Download  (3) 2010.07.21
[ C# ] Default Sound Device 변경하기  (0) 2010.07.19
[ C# ] XML 쓰고 읽기  (0) 2010.05.21
Posted by 열ㅇl