Advertisement
9usdfu98ds

AutoClicker.ps1

Jan 9th, 2023
4,968
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #########################################################################
  2. $StartupDelay       = 3000 # Time to wait before starting in milliseconds
  3. $TimeBetweenClicks  = 5000 # Time to wait between clicks in milliseconds
  4. #########################################################################
  5.  
  6. Add-Type -AssemblyName System.Windows.Forms
  7. Add-Type -AssemblyName System.Drawing
  8. $signature=@'
  9. [DllImport("user32.dll",CharSet=CharSet.Auto,CallingConvention=CallingConvention.StdCall)]
  10. public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
  11. '@
  12. $SendMouseClick = Add-Type -memberDefinition $signature -name "Win32MouseEventNew" -namespace Win32Functions -passThru
  13.  
  14. Start-Sleep -Milliseconds $StartupDelay
  15. while (1) {
  16.     $x = [System.Windows.Forms.Cursor]::Position.X
  17.     $y = [System.Windows.Forms.Cursor]::Position.Y
  18.     # Uncomment below lines to manually specify click location
  19.     # $x = 100
  20.     # $y = 100
  21.     # [System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point($x, $y)
  22.     $SendMouseClick::mouse_event(0x00000002, 0, 0, 0, 0); # Left click down
  23.     $SendMouseClick::mouse_event(0x00000004, 0, 0, 0, 0); # Left click up
  24.     Write-Output "X: $x | Y: $y"
  25.     Start-Sleep -Milliseconds $TimeBetweenClicks
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement