Add-Type @" using System; using System.Runtime.InteropServices; public class User32 { [DllImport("user32.dll")] public static extern bool GetCursorPos(out POINT lpPoint); public struct POINT { public int X; public int Y; } } "@ while ($true) { $point = New-Object User32+POINT [User32]::GetCursorPos([ref]$point) Write-Host ("X: {0} Y: {1}" -f $point.X, $point.Y) Start-Sleep -Milliseconds 100 Clear-Host }