Skip to content

Instantly share code, notes, and snippets.

@watson0x90
Created July 21, 2017 01:28
Show Gist options
  • Save watson0x90/17ffb8fe1783827b22e4e9cf4846b059 to your computer and use it in GitHub Desktop.
Save watson0x90/17ffb8fe1783827b22e4e9cf4846b059 to your computer and use it in GitHub Desktop.
Make the mouse go click
Add-Type -AssemblyName System.Windows.Forms
$screen = [System.Windows.Forms.SystemInformation]::VirtualScreen
[Windows.Forms.Cursor]::Position = "$($screen.Width),$($screen.Height)"
function Click-MouseButton
{
$signature=@'
[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);
'@
$SendMouseClick = Add-Type -memberDefinition $signature -name "Win32MouseEventNew" -namespace Win32Functions -passThru
$SendMouseClick::mouse_event(0x00000002, 0, 0, 0, 0);
$SendMouseClick::mouse_event(0x00000004, 0, 0, 0, 0);
}
Click-MouseButton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment