Ignore special keys when waiting for user input to save the logs (#9730)
Blue committed
Mar 3, 2023 at 10:34 UTC
2a0e0f7323f661d7337c156c3c48fa32ef676105
1 file changed
+35
-1
diagnostics/collect-wsl-logs.ps1
+35
-1
@@ -40,7 +40,41 @@ Get-WindowsOptionalFeature -Online > $folder/optional-components.txt
40
wpr.exe -start $LogProfile -filemode
41
42
Write-Host -NoNewLine -ForegroundColor Green "Log collection is running. Please reproduce the problem and press any key to save the logs."
43
-$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
43
+
44
+$KeysToIgnore =
45
+ 16, # Shift (left or right)
46
+ 17, # Ctrl (left or right)
47
+ 18, # Alt (left or right)
48
+ 20, # Caps lock
49
+ 91, # Windows key (left)
50
+ 92, # Windows key (right)
51
+ 93, # Menu key
52
+ 144, # Num lock
53
+ 145, # Scroll lock
54
+ 166, # Back
55
+ 167, # Forward
56
+ 168, # Refresh
57
+ 169, # Stop
58
+ 170, # Search
59
+ 171, # Favorites
60
+ 172, # Start/Home
61
+ 173, # Mute
62
+ 174, # Volume Down
63
+ 175, # Volume Up
64
+ 176, # Next Track
65
+ 177, # Previous Track
66
+ 178, # Stop Media
67
+ 179, # Play
68
+ 180, # Mail
69
+ 181, # Select Media
70
+ 182, # Application 1
71
+ 183 # Application 2
72
+
73
+$Key = $null
74
+while ($Key -Eq $null -Or $Key.VirtualKeyCode -Eq $null -Or $KeysToIgnore -Contains $Key.VirtualKeyCode)
75
+{
76
+ $Key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
77
+}
78
79
Write-Host "`nSaving logs..."
80