Skip to content

Instantly share code, notes, and snippets.

@Icaruk
Created May 22, 2022 22:14
Show Gist options
  • Save Icaruk/9f6774a2ec0d2feedd9e0fff8e0bb6fe to your computer and use it in GitHub Desktop.
Save Icaruk/9f6774a2ec0d2feedd9e0fff8e0bb6fe to your computer and use it in GitHub Desktop.
Prints mouse coordinates every X seconds
$Interval = Read-Host -Prompt 'Write time interval in seconds. Default is 1 second'
if ($Interval -le 0) {
$Interval = 1
}
if ($Interval -lt 0.25) {
$Interval = 0.25
}
Write-Host -ForegroundColor Yellow "Interval = $Interval seconds"
Write-Host "Press ctrl + C to stop"
Write-Host -ForegroundColor Green "Starting..."
start-sleep -seconds 2
while (1 -eq 1 ){
Add-Type -AssemblyName System.Windows.Forms
$X = [System.Windows.Forms.Cursor]::Position.X
$Y = [System.Windows.Forms.Cursor]::Position.Y
Write-Output "X: $X | Y: $Y"
start-sleep -seconds $Interval
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment