mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-14 14:45:52 -06:00
update Explorerrefresh
- change Invoke-WinUtilExplorerRefresh to handle refresh and restart - add restart logic to window snapping Flyout & Suggestions - rename Invoke-WinUtilExplorerRefresh to Invoke-WinUtilExplorerUpdate
This commit is contained in:
parent
667d96c397
commit
ff91167af4
@ -3311,12 +3311,12 @@
|
||||
],
|
||||
"InvokeScript": [
|
||||
"
|
||||
Invoke-WinUtilExplorerRefresh
|
||||
Invoke-WinUtilExplorerUpdate
|
||||
"
|
||||
],
|
||||
"UndoScript": [
|
||||
"
|
||||
Invoke-WinUtilExplorerRefresh
|
||||
Invoke-WinUtilExplorerUpdate
|
||||
"
|
||||
],
|
||||
"link": "https://christitustech.github.io/winutil/dev/tweaks/Customize-Preferences/DarkMode"
|
||||
@ -3416,6 +3416,16 @@
|
||||
"Type": "DWord"
|
||||
}
|
||||
],
|
||||
"InvokeScript": [
|
||||
"
|
||||
Invoke-WinUtilExplorerUpdate -action \"restart\"
|
||||
"
|
||||
],
|
||||
"UndoScript": [
|
||||
"
|
||||
Invoke-WinUtilExplorerUpdate -action \"restart\"
|
||||
"
|
||||
],
|
||||
"link": "https://christitustech.github.io/winutil/dev/tweaks/Customize-Preferences/SnapFlyout"
|
||||
},
|
||||
"WPFToggleSnapSuggestion": {
|
||||
@ -3434,6 +3444,16 @@
|
||||
"Type": "DWord"
|
||||
}
|
||||
],
|
||||
"InvokeScript": [
|
||||
"
|
||||
Invoke-WinUtilExplorerUpdate -action \"restart\"
|
||||
"
|
||||
],
|
||||
"UndoScript": [
|
||||
"
|
||||
Invoke-WinUtilExplorerUpdate -action \"restart\"
|
||||
"
|
||||
],
|
||||
"link": "https://christitustech.github.io/winutil/dev/tweaks/Customize-Preferences/SnapSuggestion"
|
||||
},
|
||||
"WPFToggleMouseAcceleration": {
|
||||
|
@ -1,33 +0,0 @@
|
||||
function Invoke-WinUtilExplorerRefresh {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Refreshes the Windows Explorer
|
||||
#>
|
||||
|
||||
Invoke-WPFRunspace -DebugPreference $DebugPreference -ScriptBlock {
|
||||
# Send the WM_SETTINGCHANGE message to all windows
|
||||
Add-Type -TypeDefinition @"
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
public class Win32 {
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||
public static extern IntPtr SendMessageTimeout(
|
||||
IntPtr hWnd,
|
||||
uint Msg,
|
||||
IntPtr wParam,
|
||||
string lParam,
|
||||
uint fuFlags,
|
||||
uint uTimeout,
|
||||
out IntPtr lpdwResult);
|
||||
}
|
||||
"@
|
||||
|
||||
$HWND_BROADCAST = [IntPtr]0xffff
|
||||
$WM_SETTINGCHANGE = 0x1A
|
||||
$SMTO_ABORTIFHUNG = 0x2
|
||||
$timeout = 100
|
||||
|
||||
# Send the broadcast message to all windows
|
||||
[Win32]::SendMessageTimeout($HWND_BROADCAST, $WM_SETTINGCHANGE, [IntPtr]::Zero, "ImmersiveColorSet", $SMTO_ABORTIFHUNG, $timeout, [ref]([IntPtr]::Zero))
|
||||
}
|
||||
}
|
43
functions/private/Invoke-WinUtilExplorerUpdate.ps1
Normal file
43
functions/private/Invoke-WinUtilExplorerUpdate.ps1
Normal file
@ -0,0 +1,43 @@
|
||||
function Invoke-WinUtilExplorerUpdate {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Refreshes the Windows Explorer
|
||||
#>
|
||||
|
||||
param (
|
||||
[string]$action = "refresh"
|
||||
)
|
||||
|
||||
if ($action -eq "refresh") {
|
||||
Invoke-WPFRunspace -DebugPreference $DebugPreference -ScriptBlock {
|
||||
# Send the WM_SETTINGCHANGE message to all windows
|
||||
Add-Type -TypeDefinition @"
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
public class Win32 {
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||
public static extern IntPtr SendMessageTimeout(
|
||||
IntPtr hWnd,
|
||||
uint Msg,
|
||||
IntPtr wParam,
|
||||
string lParam,
|
||||
uint fuFlags,
|
||||
uint uTimeout,
|
||||
out IntPtr lpdwResult);
|
||||
}
|
||||
"@
|
||||
|
||||
$HWND_BROADCAST = [IntPtr]0xffff
|
||||
$WM_SETTINGCHANGE = 0x1A
|
||||
$SMTO_ABORTIFHUNG = 0x2
|
||||
$timeout = 100
|
||||
|
||||
# Send the broadcast message to all windows
|
||||
[Win32]::SendMessageTimeout($HWND_BROADCAST, $WM_SETTINGCHANGE, [IntPtr]::Zero, "ImmersiveColorSet", $SMTO_ABORTIFHUNG, $timeout, [ref]([IntPtr]::Zero))
|
||||
}
|
||||
} elseif ($action -eq "restart") {
|
||||
# Restart the Windows Explorer
|
||||
taskkill.exe /F /IM "explorer.exe"
|
||||
Start-Process "explorer.exe"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user