-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd50734
commit d59a6fb
Showing
4 changed files
with
64 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
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,32 @@ | ||
Add-Type -TypeDefinition ' | ||
using System.Drawing; | ||
using System.Runtime.InteropServices; | ||
public static class ColorSetter { | ||
[DllImport("user32.dll")] | ||
private static extern bool SetSysColors( | ||
int cElements, | ||
int[] lpaElements, | ||
int[] lpaRgbValues | ||
); | ||
[DllImport("user32.dll")] | ||
private static extern bool SystemParametersInfo( | ||
uint uiAction, | ||
uint uiParam, | ||
string pvParam, | ||
uint fWinIni | ||
); | ||
public static void SetDesktopBackground(Color color) { | ||
SystemParametersInfo(20, 0, "", 0); | ||
SetSysColors(1, new int[] { 1 }, new int[] { ColorTranslator.ToWin32(color) }); | ||
} | ||
} | ||
' -ReferencedAssemblies 'System.Drawing'; | ||
|
||
$color = [System.Drawing.ColorTranslator]::FromHtml( $htmlColor ); | ||
[ColorSetter]::SetDesktopBackground( $color ); | ||
Set-ItemProperty -Path 'Registry::HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Wallpapers' -Name 'BackgroundType' -Type 'DWord' -Value 1 -Force; | ||
Set-ItemProperty -Path 'Registry::HKCU\Control Panel\Desktop' -Name 'WallPaper' -Type 'String' -Value '' -Force; | ||
Set-ItemProperty -Path 'Registry::HKCU\Control Panel\Colors' -Name 'Background' -Type 'String' -Value "$($color.R) $($color.G) $($color.B)" -Force; |