-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ep refresh for dark mode toggle (#2732)
- Loading branch information
1 parent
06baebc
commit 1ee7274
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
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)) | ||
} | ||
} |