Skip to content

Instantly share code, notes, and snippets.

@tomesparon
Created December 17, 2024 16:06
Show Gist options
  • Save tomesparon/6e6a2f0c2f98409aeeefc2aa0aa9729c to your computer and use it in GitHub Desktop.
Save tomesparon/6e6a2f0c2f98409aeeefc2aa0aa9729c to your computer and use it in GitHub Desktop.
Auto clicker
# Add necessary types for mouse events
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class Mouse {
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
public const int MOUSEEVENTF_LEFTDOWN = 0x02;
public const int MOUSEEVENTF_LEFTUP = 0x04;
}
"@
# Function to perform a mouse click
function Click-Mouse {
[Mouse]::mouse_event([Mouse]::MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
[Mouse]::mouse_event([Mouse]::MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
}
# Number of clicks
$clicks = 60
# Wait for 3 seconds
Start-Sleep -Seconds 3
# Perform the clicks
for ($i = 0; $i -lt $clicks; $i++) {
Click-Mouse
Start-Sleep -Milliseconds 500 # Adjust the delay between clicks if needed
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment