Issue seemed to be trying to compare directly against pos.X and pos.Y -- I added 2 more variables $a and $b to compare against.
Add-Type -AssemblyName System.Windows.Forms
$pos = [System.Windows.Forms.Cursor]::Position
$x = $pos.X
$y = $pos.Y
$a = $x
$b = $y
while ($true)
{
if ($x -eq $a -and $y -eq $b)
{
for ($i = 0; $i -lt 2500; $i++)
{
$pos = [System.Windows.Forms.Cursor]::Position
$x = [int]($pos.X % 1024) + 1
$y = [int]($pos.Y % 768) + 1
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point($x, $y)
for ($d = 0; $d -lt 1000; $d++) {}
}
}
else
{
$pos = [System.Windows.Forms.Cursor]::Position
$x = $pos.X
$y = $pos.Y
$a = $x
$b = $y
}
Start-Sleep -Seconds 5
$pos = [System.Windows.Forms.Cursor]::Position
$x = [int]$pos.X
$y = [int]$pos.Y
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…