[DllImport(“User32”)] public extern static void SetCursorPos(int x, int y);

public enum MouseEventFlags { Move = 0x0001, // Move the mouse LeftDown = 0x0002,// Simulate the left mouse button to push LeftUp = 0x0004,// Simulate the left mouse button to push RightDown = 0x0008,// Right mouse button to push RightUp = 0x0010,// Right mouse button to push up MiddleDown = 0x0020,// Middle mouse button down = 0x0040,// middle mouse button up Wheel = 0x0800, Absolute = 0x8000

private void button2_Click(object sender, EventArgs e) { RECT rect = new RECT(); GetWindowRect(hwnd, ref rect); int width = rect.Right – rect.Left; // Width of window int height = rect. bottom-rect. Top; Int x = rect.Left; int y = rect.Top; SetCursorPos(x+50, y+50); mouse_event((int)(MouseEventFlags.LeftDown | MouseEventFlags.Absolute), x, y, 0, IntPtr.Zero); mouse_event((int)(MouseEventFlags.LeftUp | MouseEventFlags.Absolute), x, y, 0, IntPtr.Zero); //mouse_event((int)(MouseEventFlags.LeftDown | MouseEventFlags.Absolute), x, y, 0, IntPtr.Zero); // mouse_event((int)(MouseEventFlags.LeftUp | MouseEventFlags.Absolute), x, y, 0, IntPtr.Zero); }