Skip to content

move-mouse-pointer

Moves the mouse pointer

#Requires -Version 5.1

param([int]$x = -1, [int]$y = -1)

try {
	Add-Type -AssemblyName System.Windows.Forms

	if (($x -eq -1) -and ($y -eq -1)) {
		$Pos = [System.Windows.Forms.Cursor]::Position
		$x = $pos.X + 5
		$y = $pos.Y + 5
	}
	[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point($x, $y)
	exit 0
} catch {
throw
}

Specifies the x coordinate in pixels

Specifies the y coordinate in pixels

An interactive directory of PowerShell scripts.