mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-04-03 14:06:27 +00:00
Add warning about some changes requiring a reboot & fix focus loss after Explorer restart (#506)
This commit is contained in:
@@ -702,6 +702,7 @@
|
|||||||
"ApplyText": "Turning off Enhanced Pointer Precision...",
|
"ApplyText": "Turning off Enhanced Pointer Precision...",
|
||||||
"UndoAction": "Enable",
|
"UndoAction": "Enable",
|
||||||
"RegistryUndoKey": "Enable_Enhance_Pointer_Precision.reg",
|
"RegistryUndoKey": "Enable_Enhance_Pointer_Precision.reg",
|
||||||
|
"RequiresReboot": true,
|
||||||
"MinVersion": null,
|
"MinVersion": null,
|
||||||
"MaxVersion": null
|
"MaxVersion": null
|
||||||
},
|
},
|
||||||
@@ -715,6 +716,7 @@
|
|||||||
"ApplyText": "Disabling the Sticky Keys keyboard shortcut...",
|
"ApplyText": "Disabling the Sticky Keys keyboard shortcut...",
|
||||||
"UndoAction": "Enable",
|
"UndoAction": "Enable",
|
||||||
"RegistryUndoKey": "Enable_Sticky_Keys_Shortcut.reg",
|
"RegistryUndoKey": "Enable_Sticky_Keys_Shortcut.reg",
|
||||||
|
"RequiresReboot": true,
|
||||||
"MinVersion": 26100,
|
"MinVersion": 26100,
|
||||||
"MaxVersion": null
|
"MaxVersion": null
|
||||||
},
|
},
|
||||||
@@ -1236,6 +1238,7 @@
|
|||||||
"ApplyText": "Disabling animations and visual effects...",
|
"ApplyText": "Disabling animations and visual effects...",
|
||||||
"UndoAction": "Enable",
|
"UndoAction": "Enable",
|
||||||
"RegistryUndoKey": "Enable_Animations.reg",
|
"RegistryUndoKey": "Enable_Animations.reg",
|
||||||
|
"RequiresReboot": true,
|
||||||
"MinVersion": null,
|
"MinVersion": null,
|
||||||
"MaxVersion": null
|
"MaxVersion": null
|
||||||
},
|
},
|
||||||
@@ -1384,13 +1387,14 @@
|
|||||||
{
|
{
|
||||||
"FeatureId": "EnableWindowsSandbox",
|
"FeatureId": "EnableWindowsSandbox",
|
||||||
"Label": "Windows Sandbox",
|
"Label": "Windows Sandbox",
|
||||||
"ToolTip": "Windows Sandbox is a lightweight desktop environment for safely running applications in isolation. Software installed inside the Windows Sandbox environment remains 'sandboxed' and runs separately from the host machine. Only supported on Windows 11 Pro, Workstation, and Enterprise editions.",
|
"ToolTip": "Windows Sandbox is a lightweight desktop environment for safely running applications in isolation. Software installed inside the Windows Sandbox environment remains 'sandboxed' and runs separately from the host machine. Only supported on Windows 11 Pro, Workstation, and Enterprise editions.",
|
||||||
"Category": "Optional Windows Features",
|
"Category": "Optional Windows Features",
|
||||||
"Action": "Enable",
|
"Action": "Enable",
|
||||||
"RegistryKey": null,
|
"RegistryKey": null,
|
||||||
"ApplyText": "Enabling Windows Sandbox...",
|
"ApplyText": "Enabling Windows Sandbox...",
|
||||||
"UndoAction": null,
|
"UndoAction": null,
|
||||||
"RegistryUndoKey": null,
|
"RegistryUndoKey": null,
|
||||||
|
"RequiresReboot": true,
|
||||||
"MinVersion": 22483,
|
"MinVersion": 22483,
|
||||||
"MaxVersion": null
|
"MaxVersion": null
|
||||||
},
|
},
|
||||||
@@ -1404,6 +1408,7 @@
|
|||||||
"ApplyText": "Enabling Windows Subsystem for Linux...",
|
"ApplyText": "Enabling Windows Subsystem for Linux...",
|
||||||
"UndoAction": null,
|
"UndoAction": null,
|
||||||
"RegistryUndoKey": null,
|
"RegistryUndoKey": null,
|
||||||
|
"RequiresReboot": true,
|
||||||
"MinVersion": 22000,
|
"MinVersion": 22000,
|
||||||
"MaxVersion": null
|
"MaxVersion": null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,10 +141,35 @@
|
|||||||
Style="{DynamicResource ModalTitleStyle}"/>
|
Style="{DynamicResource ModalTitleStyle}"/>
|
||||||
|
|
||||||
<TextBlock x:Name="ApplyCompletionMessage"
|
<TextBlock x:Name="ApplyCompletionMessage"
|
||||||
Text="Your clean system is ready. Thanks for using Win11Debloat!"
|
Text="Please note that some changes will only take effect after a reboot. Thanks for using Win11Debloat!"
|
||||||
|
TextWrapping="Wrap"
|
||||||
Style="{DynamicResource ModalSubtextStyle}"/>
|
Style="{DynamicResource ModalSubtextStyle}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
<!-- Reboot required section -->
|
||||||
|
<Border x:Name="ApplyRebootPanel"
|
||||||
|
Visibility="Collapsed"
|
||||||
|
BorderBrush="{DynamicResource BorderColor}"
|
||||||
|
BorderThickness="0,1,0,1"
|
||||||
|
Padding="24,12,24,14">
|
||||||
|
<StackPanel>
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="0,0,0,6">
|
||||||
|
<TextBlock Text=""
|
||||||
|
FontFamily="Segoe Fluent Icons"
|
||||||
|
FontSize="14"
|
||||||
|
Foreground="#e8912d"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Margin="0,0,8,0"/>
|
||||||
|
<TextBlock Text="A restart is required for these changes to take effect:"
|
||||||
|
FontSize="13"
|
||||||
|
FontWeight="SemiBold"
|
||||||
|
Foreground="{DynamicResource FgColor}"
|
||||||
|
VerticalAlignment="Center"/>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel x:Name="ApplyRebootList" Margin="22,0,0,0"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
|
||||||
<!-- Button Panel -->
|
<!-- Button Panel -->
|
||||||
<Border Background="{DynamicResource BgColor}"
|
<Border Background="{DynamicResource BgColor}"
|
||||||
BorderBrush="{DynamicResource BorderColor}"
|
BorderBrush="{DynamicResource BorderColor}"
|
||||||
|
|||||||
@@ -7,6 +7,26 @@ function Show-ApplyModal {
|
|||||||
)
|
)
|
||||||
|
|
||||||
Add-Type -AssemblyName PresentationFramework,PresentationCore,WindowsBase | Out-Null
|
Add-Type -AssemblyName PresentationFramework,PresentationCore,WindowsBase | Out-Null
|
||||||
|
|
||||||
|
# P/Invoke helpers for forcing focus back after Explorer restart
|
||||||
|
if (-not ([System.Management.Automation.PSTypeName]'Win11Debloat.FocusHelper').Type) {
|
||||||
|
Add-Type -Namespace Win11Debloat -Name FocusHelper -MemberDefinition @'
|
||||||
|
[DllImport("user32.dll")] public static extern bool SetForegroundWindow(IntPtr hWnd);
|
||||||
|
[DllImport("user32.dll")] public static extern IntPtr GetForegroundWindow();
|
||||||
|
[DllImport("user32.dll")] public static extern uint GetWindowThreadProcessId(IntPtr hWnd, IntPtr lpdwProcessId);
|
||||||
|
[DllImport("user32.dll")] public static extern bool AttachThreadInput(uint idAttach, uint idAttachTo, bool fAttach);
|
||||||
|
[DllImport("kernel32.dll")] public static extern uint GetCurrentThreadId();
|
||||||
|
|
||||||
|
public static void ForceActivate(IntPtr hwnd) {
|
||||||
|
IntPtr fg = GetForegroundWindow();
|
||||||
|
uint fgThread = GetWindowThreadProcessId(fg, IntPtr.Zero);
|
||||||
|
uint myThread = GetCurrentThreadId();
|
||||||
|
if (fgThread != myThread) AttachThreadInput(myThread, fgThread, true);
|
||||||
|
SetForegroundWindow(hwnd);
|
||||||
|
if (fgThread != myThread) AttachThreadInput(myThread, fgThread, false);
|
||||||
|
}
|
||||||
|
'@
|
||||||
|
}
|
||||||
|
|
||||||
$usesDarkMode = GetSystemUsesDarkMode
|
$usesDarkMode = GetSystemUsesDarkMode
|
||||||
|
|
||||||
@@ -55,6 +75,8 @@ function Show-ApplyModal {
|
|||||||
$script:ApplyCompletionTitleEl = $applyWindow.FindName('ApplyCompletionTitle')
|
$script:ApplyCompletionTitleEl = $applyWindow.FindName('ApplyCompletionTitle')
|
||||||
$script:ApplyCompletionMessageEl = $applyWindow.FindName('ApplyCompletionMessage')
|
$script:ApplyCompletionMessageEl = $applyWindow.FindName('ApplyCompletionMessage')
|
||||||
$script:ApplyCompletionIconEl = $applyWindow.FindName('ApplyCompletionIcon')
|
$script:ApplyCompletionIconEl = $applyWindow.FindName('ApplyCompletionIcon')
|
||||||
|
$applyRebootPanel = $applyWindow.FindName('ApplyRebootPanel')
|
||||||
|
$applyRebootList = $applyWindow.FindName('ApplyRebootList')
|
||||||
$applyCloseBtn = $applyWindow.FindName('ApplyCloseBtn')
|
$applyCloseBtn = $applyWindow.FindName('ApplyCloseBtn')
|
||||||
$applyKofiBtn = $applyWindow.FindName('ApplyKofiBtn')
|
$applyKofiBtn = $applyWindow.FindName('ApplyKofiBtn')
|
||||||
$applyCancelBtn = $applyWindow.FindName('ApplyCancelBtn')
|
$applyCancelBtn = $applyWindow.FindName('ApplyCancelBtn')
|
||||||
@@ -104,6 +126,13 @@ function Show-ApplyModal {
|
|||||||
# Restart explorer if requested
|
# Restart explorer if requested
|
||||||
if ($RestartExplorer -and -not $script:CancelRequested) {
|
if ($RestartExplorer -and -not $script:CancelRequested) {
|
||||||
RestartExplorer
|
RestartExplorer
|
||||||
|
|
||||||
|
# Wait for Explorer to finish relaunching, then reclaim focus.
|
||||||
|
Start-Sleep -Milliseconds 800
|
||||||
|
$applyWindow.Dispatcher.Invoke([action]{
|
||||||
|
$hwnd = (New-Object System.Windows.Interop.WindowInteropHelper($applyWindow)).Handle
|
||||||
|
[Win11Debloat.FocusHelper]::ForceActivate($hwnd)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
@@ -125,7 +154,33 @@ function Show-ApplyModal {
|
|||||||
$script:ApplyCompletionMessageEl.Text = "Script execution was cancelled by the user."
|
$script:ApplyCompletionMessageEl.Text = "Script execution was cancelled by the user."
|
||||||
} else {
|
} else {
|
||||||
$script:ApplyCompletionTitleEl.Text = "Changes Applied"
|
$script:ApplyCompletionTitleEl.Text = "Changes Applied"
|
||||||
$script:ApplyCompletionMessageEl.Text = "Your clean system is ready. Thanks for using Win11Debloat!"
|
|
||||||
|
# Show completion message with reboot instructions if any applied features require reboot
|
||||||
|
if ($RestartExplorer) {
|
||||||
|
$rebootFeatures = @()
|
||||||
|
foreach ($paramKey in $script:Params.Keys) {
|
||||||
|
if ($script:Features.ContainsKey($paramKey) -and $script:Features[$paramKey].RequiresReboot -eq $true) {
|
||||||
|
$feature = $script:Features[$paramKey]
|
||||||
|
$rebootFeatures += "$($feature.Action) $($feature.Label)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($rebootFeatures.Count -gt 0) {
|
||||||
|
foreach ($featureName in $rebootFeatures) {
|
||||||
|
$tb = [System.Windows.Controls.TextBlock]::new()
|
||||||
|
$tb.Text = "$([char]0x2022) $featureName"
|
||||||
|
$tb.FontSize = 12
|
||||||
|
$tb.SetResourceReference([System.Windows.Controls.TextBlock]::ForegroundProperty, 'FgColor')
|
||||||
|
$tb.Opacity = 0.85
|
||||||
|
$tb.Margin = [System.Windows.Thickness]::new(0, 2, 0, 0)
|
||||||
|
$applyRebootList.Children.Add($tb) | Out-Null
|
||||||
|
}
|
||||||
|
$applyRebootPanel.Visibility = 'Visible'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$script:ApplyCompletionMessageEl.Text = "Your clean system is ready. Thanks for using Win11Debloat!"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$applyWindow.Dispatcher.Invoke([System.Windows.Threading.DispatcherPriority]::Render, [action]{})
|
$applyWindow.Dispatcher.Invoke([System.Windows.Threading.DispatcherPriority]::Render, [action]{})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1203,7 +1203,7 @@ function Show-MainWindow {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
$message = ($changesList | ForEach-Object { "- $_" }) -join "`n"
|
$message = ($changesList | ForEach-Object { "$([char]0x2022) $_" }) -join "`n"
|
||||||
Show-MessageBox -Message $message -Title 'Selected Changes' -Button 'OK' -Icon 'None' -Width 600
|
Show-MessageBox -Message $message -Title 'Selected Changes' -Button 'OK' -Icon 'None' -Width 600
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1146,24 +1146,11 @@ function RestartExplorer {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($script:Params.ContainsKey("EnableWindowsSandbox")) {
|
foreach ($paramKey in $script:Params.Keys) {
|
||||||
Write-Host "Warning: The Windows Sandbox feature will only be available after a reboot" -ForegroundColor Yellow
|
if ($script:Features.ContainsKey($paramKey) -and $script:Features[$paramKey].RequiresReboot -eq $true) {
|
||||||
}
|
$feature = $script:Features[$paramKey]
|
||||||
|
Write-Host "Warning: '$($feature.Action) $($feature.Label)' requires a reboot to take full effect" -ForegroundColor Yellow
|
||||||
if ($script:Params.ContainsKey("EnableWindowsSubsystemForLinux")) {
|
}
|
||||||
Write-Host "Warning: The Windows Subsystem for Linux feature will only be available after a reboot" -ForegroundColor Yellow
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($script:Params.ContainsKey("DisableMouseAcceleration")) {
|
|
||||||
Write-Host "Warning: Changes to the Enhance Pointer Precision setting will only take effect after a reboot" -ForegroundColor Yellow
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($script:Params.ContainsKey("DisableStickyKeys")) {
|
|
||||||
Write-Host "Warning: Changes to the Sticky Keys setting will only take effect after a reboot" -ForegroundColor Yellow
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($script:Params.ContainsKey("DisableAnimations")) {
|
|
||||||
Write-Host "Warning: Animations will only be disabled after a reboot" -ForegroundColor Yellow
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Only restart if the powershell process matches the OS architecture.
|
# Only restart if the powershell process matches the OS architecture.
|
||||||
|
|||||||
Reference in New Issue
Block a user