Created
February 25, 2021 00:52
-
-
Save dylanlangston/8a16afb9ee8b49528ffb40b33a254100 to your computer and use it in GitHub Desktop.
Simple C# program to click the mouse on repeat.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Drawing; | |
using System.Windows.Forms; | |
using System.Runtime.InteropServices; | |
// Simple program to click the mouse on repeat. | |
namespace ClickMouseLoop | |
{ | |
class Program | |
{ | |
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] | |
public static extern void mouse_event(uint dwFlags, int dx, int dy, uint cButtons, uint dwExtraInfo); | |
private const int MOUSEEVENTF_LEFTDOWN = 0x02; | |
private const int MOUSEEVENTF_LEFTUP = 0x04; | |
static void Main() | |
{ | |
while(true) | |
{ | |
System.Threading.Thread.Sleep(10000); | |
int uX = Cursor.Position.X; | |
int uY = Cursor.Position.Y; | |
DoMouseClick(uX, uY); | |
Console.WriteLine(DateTime.Now.ToString() + " - X:" + uX + " Y:"+ uY); | |
} | |
} | |
private static void DoMouseClick(int X, int Y) | |
{ | |
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, 0, 0); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment