C#

C# WinAPI - SendMessage MouseClick

hwanjung 2022. 3. 24. 13:04
using System.Runtime.InteropServices;

[DllImport("user32.dll")]
private static extern int SendMessage(IntPtr hwnd, uint wMsg, int wParam, IntPtr lParam);

private void SendClick(IntPtr handle, int X, int Y)
{
	SendMessage(handle, (uint)WMessages.WM_LBUTTONDOWN, 1, new IntPtr(Y * 0x10000 + X));
	SendMessage(handle, (uint)WMessages.WM_LBUTTONUP, 0, new IntPtr(Y * 0x10000 + X));
}