feat: enhance swipe and back navigation logic
- Adjusted configuration for reset after swipes to 10 seconds and added action to go back. - Updated flow control to skip back action if a recent reset was triggered within 5 seconds. - Implemented a mechanism to enable back navigation when consecutive misses reach a threshold. - Added GUI options to enable or disable back navigation on misses, ensuring consistency with user settings. - Introduced new diagnostic tools for runtime flag checks and screenshot diagnostics. - Created PowerShell scripts for restoring Start Menu shortcuts and performing system health checks. - Added tests for swipe operations and back navigation to validate new logic.
This commit is contained in:
1 parent
0c3a763d63
commit
dcded08796
19 files changed
+936
-22
No files matched your search
@@ -0,0 +1,107 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[switch]$WhatIf
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
function Write-Section([string]$title) {
|
||||
Write-Host ""
|
||||
Write-Host "=== $title ==="
|
||||
}
|
||||
|
||||
$programsUser = Join-Path $env:APPDATA 'Microsoft\Windows\Start Menu\Programs'
|
||||
$programsCommon = Join-Path $env:ProgramData 'Microsoft\Windows\Start Menu\Programs'
|
||||
|
||||
Write-Section 'Targets'
|
||||
Write-Host "ProgramsUser: $programsUser"
|
||||
Write-Host "ProgramsCommon: $programsCommon"
|
||||
Write-Host "WhatIf: $WhatIf"
|
||||
|
||||
Write-Section 'Enumerate Recycle Bin'
|
||||
$shell = New-Object -ComObject Shell.Application
|
||||
$recycle = $shell.Namespace(0xA)
|
||||
if ($null -eq $recycle) {
|
||||
throw 'Failed to open Recycle Bin namespace.'
|
||||
}
|
||||
|
||||
$items = @($recycle.Items())
|
||||
Write-Host "RecycleBin items: $($items.Count)"
|
||||
|
||||
function Get-DeletedFrom($item) {
|
||||
try { return $item.ExtendedProperty('System.Recycle.DeletedFrom') } catch { return $null }
|
||||
}
|
||||
|
||||
function Get-OriginalName($item) {
|
||||
try { return $item.Name } catch { return $null }
|
||||
}
|
||||
|
||||
function Find-RestoreVerb($item) {
|
||||
try {
|
||||
$verbs = @($item.Verbs())
|
||||
foreach ($v in $verbs) {
|
||||
$name = ($v.Name -as [string])
|
||||
if ([string]::IsNullOrWhiteSpace($name)) { continue }
|
||||
$n = $name.Replace('&','').Trim()
|
||||
if ($n -match '(?i)restore' -or $n -match '还原') {
|
||||
return $n
|
||||
}
|
||||
}
|
||||
} catch { }
|
||||
return $null
|
||||
}
|
||||
|
||||
$matches = @()
|
||||
foreach ($it in $items) {
|
||||
$deletedFrom = Get-DeletedFrom $it
|
||||
$name = Get-OriginalName $it
|
||||
if ([string]::IsNullOrWhiteSpace($name)) { continue }
|
||||
|
||||
$isLnk = $name.ToLowerInvariant().EndsWith('.lnk')
|
||||
if (!$isLnk) { continue }
|
||||
|
||||
if ($deletedFrom -and (
|
||||
$deletedFrom -like "$programsUser*" -or
|
||||
$deletedFrom -like "$programsCommon*" -or
|
||||
$deletedFrom -like '*\\Microsoft\\Windows\\Start Menu\\Programs*'
|
||||
)) {
|
||||
$matches += [pscustomobject]@{ Name = $name; DeletedFrom = $deletedFrom; Item = $it }
|
||||
}
|
||||
}
|
||||
|
||||
Write-Section 'Matches'
|
||||
Write-Host "Matching .lnk from Start Menu Programs: $($matches.Count)"
|
||||
$matches | Select-Object -First 50 Name,DeletedFrom | Format-List
|
||||
|
||||
if ($matches.Count -eq 0) {
|
||||
Write-Host 'No matching shortcuts found in Recycle Bin.'
|
||||
exit 0
|
||||
}
|
||||
|
||||
if ($WhatIf) {
|
||||
Write-Host 'WhatIf set; not restoring.'
|
||||
exit 0
|
||||
}
|
||||
|
||||
Write-Section 'Restore'
|
||||
$restored = 0
|
||||
$skipped = 0
|
||||
foreach ($m in $matches) {
|
||||
$it = $m.Item
|
||||
$verb = Find-RestoreVerb $it
|
||||
if ([string]::IsNullOrWhiteSpace($verb)) {
|
||||
$skipped++
|
||||
continue
|
||||
}
|
||||
|
||||
try {
|
||||
$it.InvokeVerb($verb)
|
||||
$restored++
|
||||
} catch {
|
||||
$skipped++
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Restored: $restored"
|
||||
Write-Host "Skipped: $skipped"
|
||||
Write-Host 'Tip: If restore succeeded, restart Explorer / Start menu.'
|
||||
Reference in new issue
Block a user