diff --git a/resources/desktop-picker.ps1 b/resources/desktop-picker.ps1 index 7797001..61c97c4 100644 --- a/resources/desktop-picker.ps1 +++ b/resources/desktop-picker.ps1 @@ -79,6 +79,10 @@ $hl.Show() $stage = "hover" $chain = New-Object System.Collections.ArrayList $selIdx = -1 +$script:lastX = -1 +$script:lastY = -1 +$script:lastMove = Get-Date +$script:pending = $false $prevSpace = $false $prevPgUp = $false $prevPgDn = $false @@ -94,6 +98,13 @@ while ($true) { if ($stage -eq "hover") { $ptX = [System.Windows.Forms.Cursor]::Position.X $ptY = [System.Windows.Forms.Cursor]::Position.Y + if ($ptX -ne $script:lastX -or $ptY -ne $script:lastY) { + $script:lastX = $ptX; $script:lastY = $ptY + $script:lastMove = Get-Date + $script:pending = $true + } + $idle = ((Get-Date) - $script:lastMove).TotalMilliseconds -ge 250 + if (-not $idle) { Start-Sleep -Milliseconds 60; return } $el = Get-DeepestAtPoint $ptX $ptY if ($el) { $c = $el.Current