PowerShell Mouse Click

70次阅读
没有评论
[system.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | out-null
#Get current Position

$x = [System.Windows.Forms.Cursor]::Position.X
$y = [System.Windows.Forms.Cursor]::Position.Y
#Set click position
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point($x,$y)
$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 
#Send mouse click event
$SendMouseClick::mouse_event(0x00000002, 0, 0, 0, 0);
$SendMouseClick::mouse_event(0x00000004, 0, 0, 0, 0);
正文完
 
评论(没有评论)