-
-
Notifications
You must be signed in to change notification settings - Fork 24
Form1.cs | DoMouseClick
HackTheDev edited this page May 3, 2021
·
1 revision
This is code to make the mouse click. It includes one DLL Import as well as some variables.
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);
private const int MOUSEEVENTF_LEFTDOWN = 0x02;
private const int MOUSEEVENTF_LEFTUP = 0x04;
private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
private const int MOUSEEVENTF_RIGHTUP = 0x10;
public void DoMouseClick()
{
uint X = (uint)Screen.PrimaryScreen.WorkingArea.Width / 2;
uint Y = (uint)Screen.PrimaryScreen.WorkingArea.Height / 2;
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, 0, 0);
}
In order to change the position of where the click shoud happen, you need to change the following lines
uint X = (uint)Screen.PrimaryScreen.WorkingArea.Width / 2;
uint Y = (uint)Screen.PrimaryScreen.WorkingArea.Height / 2;
Copyright (c) Marcel Schalk - Patreon: Shy Devil