mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-04-07 11:42:08 +00:00
Merge branch 'ChrisTitusTech:main' into SSHserver
This commit is contained in:
commit
7174450fb5
.github/workflows
README.mdconfig
functions
private
Get-WinUtilToggleStatus.ps1Invoke-WinUtilDarkMode.ps1Invoke-WinUtilExplorerRefresh.ps1Invoke-WinUtilMicroWin-Helper.ps1Invoke-WinutilThemeChange.ps1Set-WinUtilUITheme.ps1Show-CustomDialog.ps1
public
scripts
xaml
42
.github/workflows/close-issue-command.yaml
vendored
42
.github/workflows/close-issue-command.yaml
vendored
@ -15,18 +15,33 @@ jobs:
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- name: Check for /close comment
|
||||
id: check_comment
|
||||
- run: echo "command=false" >> $GITHUB_ENV
|
||||
|
||||
- name: Check for /close command
|
||||
id: check_close_command
|
||||
run: |
|
||||
if [[ "${{ contains(github.event.comment.body, '/close') }}" == "true" ]]; then
|
||||
echo "comment=true" >> $GITHUB_ENV
|
||||
echo "command=true" >> $GITHUB_ENV
|
||||
echo "close_command=true" >> $GITHUB_ENV
|
||||
echo "reopen_command=false" >> $GITHUB_ENV
|
||||
else
|
||||
echo "comment=false" >> $GITHUB_ENV
|
||||
echo "close_command=false" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Check for /open or /reopen command
|
||||
id: check_reopen_command
|
||||
run: |
|
||||
if [[ "${{ contains(github.event.comment.body, '/open') }}" == "true" ]] || [[ "${{ contains(github.event.comment.body, '/reopen') }}" == "true" ]]; then
|
||||
echo "command=true" >> $GITHUB_ENV
|
||||
echo "reopen_command=true" >> $GITHUB_ENV
|
||||
echo "close_command=false" >> $GITHUB_ENV
|
||||
else
|
||||
echo "reopen_command=false" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Check if the user is allowed
|
||||
id: check_user
|
||||
if: env.comment == 'true'
|
||||
if: env.command == 'true'
|
||||
run: |
|
||||
ALLOWED_USERS=("ChrisTitusTech" "og-mrk" "Marterich" "MyDrift-user" "Real-MullaC")
|
||||
if [[ " ${ALLOWED_USERS[@]} " =~ " ${{ github.event.comment.user.login }} " ]]; then
|
||||
@ -36,10 +51,23 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Close issue if conditions are met
|
||||
if: env.comment == 'true' && env.user == 'true'
|
||||
if: env.close_command == 'true' && env.user == 'true'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
ISSUE_NUMBER: ${{ github.event.issue.number }}
|
||||
run: |
|
||||
echo Closing the issue...
|
||||
gh issue close $ISSUE_NUMBER --repo ${{ github.repository }}
|
||||
if [[ "${{ contains(github.event.comment.body, 'not planned') }}" == "true" ]]; then
|
||||
gh issue close $ISSUE_NUMBER --repo ${{ github.repository }} --reason 'not planned'
|
||||
else
|
||||
gh issue close $ISSUE_NUMBER --repo ${{ github.repository }}
|
||||
fi
|
||||
|
||||
- name: Reopen issue if conditions are met
|
||||
if: env.reopen_command == 'true' && env.user == 'true'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
ISSUE_NUMBER: ${{ github.event.issue.number }}
|
||||
run: |
|
||||
echo Reopening the issue...
|
||||
gh issue reopen $ISSUE_NUMBER --repo ${{ github.repository }}
|
@ -1,169 +1,109 @@
|
||||
{
|
||||
"_default": {
|
||||
"CustomDialogFontSize": "12",
|
||||
"CustomDialogFontSizeHeader": "14",
|
||||
"CustomDialogIconSize": "25",
|
||||
"CustomDialogWidth": "400",
|
||||
"CustomDialogHeight": "200",
|
||||
"shared":{
|
||||
"CustomDialogFontSize": "12",
|
||||
"CustomDialogFontSizeHeader": "14",
|
||||
"CustomDialogIconSize": "25",
|
||||
"CustomDialogWidth": "400",
|
||||
"CustomDialogHeight": "200",
|
||||
"FontSize": "12",
|
||||
"FontFamily": "Arial",
|
||||
"FontSizeHeading": "16",
|
||||
"HeaderFontFamily": "Consolas, Monaco",
|
||||
"CheckBoxBulletDecoratorSize": "14",
|
||||
"CheckBoxMargin": "15,0,0,2",
|
||||
"TabContentMargin": "5",
|
||||
"TabButtonFontSize": "14",
|
||||
"TabButtonWidth": "110",
|
||||
"TabButtonHeight": "26",
|
||||
"TabRowHeightInPixels": "50",
|
||||
"IconFontSize": "14",
|
||||
"IconButtonSize": "35",
|
||||
"SettingsIconFontSize": "18",
|
||||
"CloseIconFontSize": "18",
|
||||
"MicroWinLogoSize": "10",
|
||||
"MicrowinCheckBoxMargin": "-10,5,0,0",
|
||||
"GroupBorderBackgroundColor": "#232629",
|
||||
"ButtonFontSize": "12",
|
||||
"ButtonFontFamily": "Arial",
|
||||
"ButtonWidth": "200",
|
||||
"ButtonHeight": "25",
|
||||
"ConfigTabButtonFontSize": "16",
|
||||
"SearchBarWidth": "200",
|
||||
"SearchBarHeight": "26",
|
||||
"SearchBarTextBoxFontSize": "12",
|
||||
"SearchBarClearButtonFontSize": "14",
|
||||
"CheckboxMouseOverColor": "#999999",
|
||||
"ButtonBorderThickness": "1",
|
||||
"ButtonMargin": "1",
|
||||
"ButtonCornerRadius": "2"
|
||||
},
|
||||
"Light": {
|
||||
"ComboBoxForegroundColor": "#232629",
|
||||
"ComboBoxBackgroundColor": "#F7F7F7",
|
||||
"LabelboxForegroundColor": "#232629",
|
||||
"MainForegroundColor": "#232629",
|
||||
"MainBackgroundColor": "#F7F7F7",
|
||||
"LabelBackgroundColor": "#F7F7F7",
|
||||
"LinkForegroundColor": "#232629",
|
||||
"LinkHoverForegroundColor": "#232629",
|
||||
"ScrollBarBackgroundColor": "#4A4D52",
|
||||
"ScrollBarHoverColor": "#5A5D62",
|
||||
"ScrollBarDraggingColor": "#6A6D72",
|
||||
|
||||
"FontSize": "12",
|
||||
"FontFamily": "Arial",
|
||||
"FontSizeHeading": "16",
|
||||
"HeaderFontFamily": "Consolas, Monaco",
|
||||
"ProgressBarForegroundColor": "#2e77ff",
|
||||
"ProgressBarBackgroundColor": "Transparent",
|
||||
"ProgressBarTextColor": "#232629",
|
||||
"ButtonInstallBackgroundColor": "#F7F7F7",
|
||||
"ButtonTweaksBackgroundColor": "#F7F7F7",
|
||||
"ButtonConfigBackgroundColor": "#F7F7F7",
|
||||
"ButtonUpdatesBackgroundColor": "#F7F7F7",
|
||||
"ButtonInstallForegroundColor": "#232629",
|
||||
"ButtonTweaksForegroundColor": "#232629",
|
||||
"ButtonConfigForegroundColor": "#232629",
|
||||
"ButtonUpdatesForegroundColor": "#232629",
|
||||
"ButtonBackgroundColor": "#F5F5F5",
|
||||
"ButtonBackgroundPressedColor": "#1A1A1A",
|
||||
"ButtonBackgroundMouseoverColor": "#C2C2C2",
|
||||
"ButtonBackgroundSelectedColor": "#F0F0F0",
|
||||
"ButtonForegroundColor": "#232629",
|
||||
"ToggleButtonOnColor": "#2e77ff",
|
||||
"ToggleButtonOffColor": "#707070",
|
||||
"BorderColor": "#232629",
|
||||
"BorderOpacity": "0.2"
|
||||
|
||||
"CheckBoxBulletDecoratorSize": "14",
|
||||
"CheckBoxMargin": "15,0,0,2",
|
||||
},
|
||||
"Dark": {
|
||||
"ComboBoxForegroundColor": "#1e3747",
|
||||
"ComboBoxBackgroundColor": "#232629",
|
||||
"LabelboxForegroundColor": "#0567ff",
|
||||
"MainForegroundColor": "#F7F7F7",
|
||||
"MainBackgroundColor": "#121212",
|
||||
"LabelBackgroundColor": "#121212",
|
||||
"LinkForegroundColor": "#add8e6",
|
||||
"LinkHoverForegroundColor": "#F7F7F7",
|
||||
"ScrollBarBackgroundColor": "#2E3135",
|
||||
"ScrollBarHoverColor": "#3B4252",
|
||||
"ScrollBarDraggingColor": "#5E81AC",
|
||||
|
||||
"TabContentMargin": "5",
|
||||
"TabButtonFontSize": "14",
|
||||
"TabButtonWidth": "100",
|
||||
"TabButtonHeight": "25",
|
||||
"TabRowHeightInPixels": "50",
|
||||
"IconFontSize": "14",
|
||||
"IconButtonSize": "35",
|
||||
"SettingsIconFontSize": "18",
|
||||
"CloseIconFontSize": "18",
|
||||
|
||||
"MicroWinLogoSize": "10",
|
||||
"MicrowinCheckBoxMargin": "-10,5,0,0",
|
||||
|
||||
"ProgressBarForegroundColor": "#2e77ff",
|
||||
"ProgressBarBackgroundColor": "Transparent",
|
||||
"ProgressBarTextColor": "#232629",
|
||||
|
||||
"ComboBoxBackgroundColor": "#F7F7F7",
|
||||
"LabelboxForegroundColor": "#232629",
|
||||
"MainForegroundColor": "#232629",
|
||||
"MainBackgroundColor": "#F7F7F7",
|
||||
"LabelBackgroundColor": "#F7F7F7",
|
||||
"LinkForegroundColor": "#232629",
|
||||
"LinkHoverForegroundColor": "#232629",
|
||||
"GroupBorderBackgroundColor": "#232629",
|
||||
"ComboBoxForegroundColor": "#232629",
|
||||
|
||||
"ButtonFontSize": "12",
|
||||
"ButtonFontFamily": "Arial",
|
||||
"ButtonWidth": "200",
|
||||
"ButtonHeight": "25",
|
||||
"ConfigTabButtonFontSize": "16",
|
||||
|
||||
"SearchBarWidth": "200",
|
||||
"SearchBarHeight": "25",
|
||||
"SearchBarTextBoxFontSize": "12",
|
||||
"SearchBarClearButtonFontSize": "14",
|
||||
|
||||
"ButtonInstallBackgroundColor": "#F7F7F7",
|
||||
"ButtonTweaksBackgroundColor": "#F7F7F7",
|
||||
"ButtonConfigBackgroundColor": "#F7F7F7",
|
||||
"ButtonUpdatesBackgroundColor": "#F7F7F7",
|
||||
"ButtonInstallForegroundColor": "#232629",
|
||||
"ButtonTweaksForegroundColor": "#232629",
|
||||
"ButtonConfigForegroundColor": "#232629",
|
||||
"ButtonUpdatesForegroundColor": "#232629",
|
||||
"ButtonBackgroundColor": "#F5F5F5",
|
||||
"ButtonBackgroundPressedColor": "#1A1A1A",
|
||||
"CheckboxMouseOverColor": "#999999",
|
||||
"ButtonBackgroundMouseoverColor": "#C2C2C2",
|
||||
"ButtonBackgroundSelectedColor": "#F0F0F0",
|
||||
"ButtonForegroundColor": "#232629",
|
||||
"ToggleButtonOnColor": "#2e77ff",
|
||||
|
||||
"ButtonBorderThickness": "1",
|
||||
"ButtonMargin": "1",
|
||||
"ButtonCornerRadius": "2",
|
||||
"BorderColor": "#232629",
|
||||
"BorderOpacity": "0.2",
|
||||
"ShadowPulse": "Forever"
|
||||
},
|
||||
"Classic": {
|
||||
"ComboBoxBackgroundColor": "#F7F7F7",
|
||||
"LabelboxForegroundColor": "#232629",
|
||||
"MainForegroundColor": "#232629",
|
||||
"MainBackgroundColor": "#F7F7F7",
|
||||
"LabelBackgroundColor": "#F7F7F7",
|
||||
"LinkForegroundColor": "#232629",
|
||||
"LinkHoverForegroundColor": "#232629",
|
||||
"GroupBorderBackgroundColor": "#232629",
|
||||
"ComboBoxForegroundColor": "#232629",
|
||||
|
||||
"ButtonInstallBackgroundColor": "#F7F7F7",
|
||||
"ButtonTweaksBackgroundColor": "#F7F7F7",
|
||||
"ButtonConfigBackgroundColor": "#F7F7F7",
|
||||
"ButtonUpdatesBackgroundColor": "#F7F7F7",
|
||||
"ButtonInstallForegroundColor": "#232629",
|
||||
"ButtonTweaksForegroundColor": "#232629",
|
||||
"ButtonConfigForegroundColor": "#232629",
|
||||
"ButtonUpdatesForegroundColor": "#232629",
|
||||
"ButtonBackgroundColor": "#F5F5F5",
|
||||
"ButtonBackgroundPressedColor": "#1A1A1A",
|
||||
"CheckboxMouseOverColor": "#999999",
|
||||
"ButtonBackgroundMouseoverColor": "#C2C2C2",
|
||||
"ButtonBackgroundSelectedColor": "#F0F0F0",
|
||||
"ButtonForegroundColor": "#232629",
|
||||
"ToggleButtonOnColor": "#2e77ff"
|
||||
},
|
||||
"Matrix": {
|
||||
"ComboBoxBackgroundColor": "#232629",
|
||||
"LabelboxForegroundColor": "#f7f7f7",
|
||||
"MainForegroundColor": "#F7F7F7",
|
||||
"MainBackgroundColor": "#232629",
|
||||
"LabelBackgroundColor": "#232629",
|
||||
"LinkForegroundColor": "#add8e6",
|
||||
"LinkHoverForegroundColor": "#F7F7F7",
|
||||
"ComboBoxForegroundColor": "#81a1c1",
|
||||
|
||||
"ProgressBarForegroundColor": "#222222",
|
||||
"ProgressBarBackgroundColor": "Transparent",
|
||||
"ProgressBarTextColor": "#cccccc",
|
||||
|
||||
"ButtonInstallBackgroundColor": "#222222",
|
||||
"ButtonTweaksBackgroundColor": "#333333",
|
||||
"ButtonConfigBackgroundColor": "#444444",
|
||||
"ButtonUpdatesBackgroundColor": "#555555",
|
||||
"ButtonInstallForegroundColor": "#F7F7F7",
|
||||
"ButtonTweaksForegroundColor": "#F7F7F7",
|
||||
"ButtonConfigForegroundColor": "#F7F7F7",
|
||||
"ButtonUpdatesForegroundColor": "#F7F7F7",
|
||||
"ButtonBackgroundColor": "#1E3747",
|
||||
"ButtonBackgroundPressedColor": "#F7F7F7",
|
||||
"ButtonBackgroundMouseoverColor": "#3B4252",
|
||||
"ButtonBackgroundSelectedColor": "#5E81AC",
|
||||
"ButtonForegroundColor": "#F7F7F7",
|
||||
"ToggleButtonOnColor": "#2e77ff",
|
||||
|
||||
"BorderColor": "#0060CC",
|
||||
"BorderOpacity": "0.2",
|
||||
"ShadowPulse": "0:0:3"
|
||||
},
|
||||
"Dark": {
|
||||
"ComboBoxBackgroundColor": "#1e3747",
|
||||
"LabelboxForegroundColor": "#0567ff",
|
||||
"MainForegroundColor": "#F7F7F7",
|
||||
"MainBackgroundColor": "#121212",
|
||||
"LabelBackgroundColor": "#121212",
|
||||
"LinkForegroundColor": "#add8e6",
|
||||
"LinkHoverForegroundColor": "#F7F7F7",
|
||||
"ComboBoxForegroundColor": "#f7f7f7",
|
||||
|
||||
"ProgressBarForegroundColor": "#222222",
|
||||
"ProgressBarBackgroundColor": "Transparent",
|
||||
"ProgressBarTextColor": "#cccccc",
|
||||
|
||||
"ButtonInstallBackgroundColor": "#222222",
|
||||
"ButtonTweaksBackgroundColor": "#333333",
|
||||
"ButtonConfigBackgroundColor": "#444444",
|
||||
"ButtonUpdatesBackgroundColor": "#555555",
|
||||
"ButtonInstallForegroundColor": "#F7F7F7",
|
||||
"ButtonTweaksForegroundColor": "#F7F7F7",
|
||||
"ButtonConfigForegroundColor": "#F7F7F7",
|
||||
"ButtonUpdatesForegroundColor": "#F7F7F7",
|
||||
"ButtonBackgroundColor": "#1E3747",
|
||||
"ButtonBackgroundPressedColor": "#00CFFF",
|
||||
"ButtonBackgroundMouseoverColor": "#5E81AC",
|
||||
"ButtonBackgroundSelectedColor": "#5E81AC",
|
||||
"ButtonForegroundColor": "#F7F7F7",
|
||||
"ToggleButtonOnColor": "#2e77ff",
|
||||
|
||||
"BorderColor": "#2F373D"
|
||||
}
|
||||
"ProgressBarForegroundColor": "#222222",
|
||||
"ProgressBarBackgroundColor": "Transparent",
|
||||
"ProgressBarTextColor": "#cccccc",
|
||||
"ButtonInstallBackgroundColor": "#222222",
|
||||
"ButtonTweaksBackgroundColor": "#333333",
|
||||
"ButtonConfigBackgroundColor": "#444444",
|
||||
"ButtonUpdatesBackgroundColor": "#555555",
|
||||
"ButtonInstallForegroundColor": "#F7F7F7",
|
||||
"ButtonTweaksForegroundColor": "#F7F7F7",
|
||||
"ButtonConfigForegroundColor": "#F7F7F7",
|
||||
"ButtonUpdatesForegroundColor": "#F7F7F7",
|
||||
"ButtonBackgroundColor": "#1E3747",
|
||||
"ButtonBackgroundPressedColor": "#F7F7F7",
|
||||
"ButtonBackgroundMouseoverColor": "#3B4252",
|
||||
"ButtonBackgroundSelectedColor": "#5E81AC",
|
||||
"ButtonForegroundColor": "#F7F7F7",
|
||||
"ToggleButtonOnColor": "#2e77ff",
|
||||
"ToggleButtonOffColor": "#707070",
|
||||
"BorderColor": "#2F373D",
|
||||
"BorderOpacity": "0.2"
|
||||
}
|
||||
}
|
||||
|
@ -2767,6 +2767,48 @@
|
||||
],
|
||||
"link": "https://christitustech.github.io/winutil/dev/tweaks/z--Advanced-Tweaks---CAUTION/RemoveOnedrive"
|
||||
},
|
||||
"WPFTweaksRazerBlock": {
|
||||
"Content": "Block Razer Software Installs",
|
||||
"Description": "Blocks ALL Razer Software installations. The hardware works fine without any software.",
|
||||
"category": "z__Advanced Tweaks - CAUTION",
|
||||
"panel": "1",
|
||||
"Order": "a031_",
|
||||
"registry": [
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DriverSearching",
|
||||
"Name": "SearchOrderConfig",
|
||||
"Value": "0",
|
||||
"OriginalValue": "1",
|
||||
"Type": "DWord"
|
||||
},
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Device Installer",
|
||||
"Name": "DisableCoInstallers",
|
||||
"Value": "1",
|
||||
"OriginalValue": "0",
|
||||
"Type": "DWord"
|
||||
}
|
||||
],
|
||||
"InvokeScript": [
|
||||
"
|
||||
$RazerPath = \"C:\\Windows\\Installer\\Razer\"
|
||||
Remove-Item $RazerPath -Recurse -Force
|
||||
New-Item -Path \"C:\\Windows\\Installer\\\" -Name \"Razer\" -ItemType \"directory\"
|
||||
$Acl = Get-Acl $RazerPath
|
||||
$Ar = New-Object System.Security.AccessControl.FileSystemAccessRule(\"NT AUTHORITY\\SYSTEM\",\"Write\",\"ContainerInherit,ObjectInherit\",\"None\",\"Deny\")
|
||||
$Acl.SetAccessRule($Ar)
|
||||
Set-Acl $RazerPath $Acl
|
||||
"
|
||||
],
|
||||
"UndoScript": [
|
||||
"
|
||||
$RazerPath = \"C:\\Windows\\Installer\\Razer\"
|
||||
Remove-Item $RazerPath -Recurse -Force
|
||||
New-Item -Path \"C:\\Windows\\Installer\\\" -Name \"Razer\" -ItemType \"directory\"
|
||||
"
|
||||
],
|
||||
"link": "https://christitustech.github.io/winutil/dev/tweaks/Essential-Tweaks/RazerBlock"
|
||||
},
|
||||
"WPFTweaksDisableNotifications": {
|
||||
"Content": "Disable Notification Tray/Calendar",
|
||||
"Description": "Disables all Notifications INCLUDING Calendar",
|
||||
|
@ -16,136 +16,72 @@ Function Get-WinUtilToggleStatus {
|
||||
if($ToggleSwitch -eq "WPFToggleDarkMode") {
|
||||
$app = (Get-ItemProperty -path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize').AppsUseLightTheme
|
||||
$system = (Get-ItemProperty -path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize').SystemUsesLightTheme
|
||||
if($app -eq 0 -and $system -eq 0) {
|
||||
return $true
|
||||
} else {
|
||||
return $false
|
||||
}
|
||||
return $app -eq 0 -and $system -eq 0
|
||||
}
|
||||
if($ToggleSwitch -eq "WPFToggleBingSearch") {
|
||||
$bingsearch = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Search').BingSearchEnabled
|
||||
if($bingsearch -eq 0) {
|
||||
return $false
|
||||
} else {
|
||||
return $true
|
||||
}
|
||||
return $bingsearch -ne 0
|
||||
}
|
||||
if($ToggleSwitch -eq "WPFToggleNumLock") {
|
||||
$numlockvalue = (Get-ItemProperty -path 'HKCU:\Control Panel\Keyboard').InitialKeyboardIndicators
|
||||
if($numlockvalue -eq 2) {
|
||||
return $true
|
||||
} else {
|
||||
return $false
|
||||
}
|
||||
return $numlockvalue -eq 2
|
||||
}
|
||||
if($ToggleSwitch -eq "WPFToggleVerboseLogon") {
|
||||
$VerboseStatusvalue = (Get-ItemProperty -path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System').VerboseStatus
|
||||
if($VerboseStatusvalue -eq 1) {
|
||||
return $true
|
||||
} else {
|
||||
return $false
|
||||
}
|
||||
return $VerboseStatusvalue -eq 1
|
||||
}
|
||||
if($ToggleSwitch -eq "WPFToggleShowExt") {
|
||||
$hideextvalue = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced').HideFileExt
|
||||
if($hideextvalue -eq 0) {
|
||||
return $true
|
||||
} else {
|
||||
return $false
|
||||
}
|
||||
return $hideextvalue -eq 0
|
||||
}
|
||||
if($ToggleSwitch -eq "WPFToggleSnapWindow") {
|
||||
$hidesnap = (Get-ItemProperty -path 'HKCU:\Control Panel\Desktop').WindowArrangementActive
|
||||
if($hidesnap -eq 0) {
|
||||
return $false
|
||||
} else {
|
||||
return $true
|
||||
}
|
||||
return $hidesnap -ne 0
|
||||
}
|
||||
if($ToggleSwitch -eq "WPFToggleSnapFlyout") {
|
||||
$hidesnap = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced').EnableSnapAssistFlyout
|
||||
if($hidesnap -eq 0) {
|
||||
return $false
|
||||
} else {
|
||||
return $true
|
||||
}
|
||||
return $hidesnap -ne 0
|
||||
}
|
||||
if($ToggleSwitch -eq "WPFToggleSnapSuggestion") {
|
||||
$hidesnap = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced').SnapAssist
|
||||
if($hidesnap -eq 0) {
|
||||
return $false
|
||||
} else {
|
||||
return $true
|
||||
}
|
||||
return $hidesnap -ne 0
|
||||
}
|
||||
if($ToggleSwitch -eq "WPFToggleMouseAcceleration") {
|
||||
$MouseSpeed = (Get-ItemProperty -path 'HKCU:\Control Panel\Mouse').MouseSpeed
|
||||
$MouseThreshold1 = (Get-ItemProperty -path 'HKCU:\Control Panel\Mouse').MouseThreshold1
|
||||
$MouseThreshold2 = (Get-ItemProperty -path 'HKCU:\Control Panel\Mouse').MouseThreshold2
|
||||
|
||||
if($MouseSpeed -eq 1 -and $MouseThreshold1 -eq 6 -and $MouseThreshold2 -eq 10) {
|
||||
return $true
|
||||
} else {
|
||||
return $false
|
||||
}
|
||||
return $MouseSpeed -eq 1 -and $MouseThreshold1 -eq 6 -and $MouseThreshold2 -eq 10
|
||||
}
|
||||
if($ToggleSwitch -eq "WPFToggleTaskbarSearch") {
|
||||
$SearchButton = (Get-ItemProperty -path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search").SearchboxTaskbarMode
|
||||
if($SearchButton -eq 0) {
|
||||
return $false
|
||||
} else {
|
||||
return $true
|
||||
}
|
||||
return $SearchButton -ne 0
|
||||
}
|
||||
if ($ToggleSwitch -eq "WPFToggleStickyKeys") {
|
||||
$StickyKeys = (Get-ItemProperty -path 'HKCU:\Control Panel\Accessibility\StickyKeys').Flags
|
||||
if($StickyKeys -eq 58) {
|
||||
return $false
|
||||
} else {
|
||||
return $true
|
||||
}
|
||||
return $StickyKeys -ne 58
|
||||
}
|
||||
if ($ToggleSwitch -eq "WPFToggleTaskView") {
|
||||
$TaskView = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced').ShowTaskViewButton
|
||||
if($TaskView -eq 0) {
|
||||
return $false
|
||||
} else {
|
||||
return $true
|
||||
}
|
||||
return $TaskView -ne 0
|
||||
}
|
||||
|
||||
if ($ToggleSwitch -eq "WPFToggleHiddenFiles") {
|
||||
$HiddenFiles = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced').Hidden
|
||||
if($HiddenFiles -eq 0) {
|
||||
return $false
|
||||
} else {
|
||||
return $true
|
||||
}
|
||||
return $HiddenFiles -ne 0
|
||||
}
|
||||
|
||||
if ($ToggleSwitch -eq "WPFToggleTaskbarWidgets") {
|
||||
$TaskbarWidgets = (Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced").TaskBarDa
|
||||
if($TaskbarWidgets -eq 0) {
|
||||
return $false
|
||||
} else {
|
||||
return $true
|
||||
}
|
||||
return $TaskbarWidgets -ne 0
|
||||
}
|
||||
if ($ToggleSwitch -eq "WPFToggleTaskbarAlignment") {
|
||||
$TaskbarAlignment = (Get-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced").TaskbarAl
|
||||
if($TaskbarAlignment -eq 0) {
|
||||
return $false
|
||||
} else {
|
||||
return $true
|
||||
}
|
||||
return $TaskbarAlignment -ne 0
|
||||
}
|
||||
if ($ToggleSwitch -eq "WPFToggleDetailedBSoD") {
|
||||
$DetailedBSoD1 = (Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl').DisplayParameters
|
||||
$DetailedBSoD2 = (Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl').DisableEmoticon
|
||||
if (($DetailedBSoD1 -eq 0) -or ($DetailedBSoD2 -eq 0) -or !$DetailedBSoD1 -or !$DetailedBSoD2) {
|
||||
return $false
|
||||
} else {
|
||||
return $true
|
||||
}
|
||||
return !(($DetailedBSoD1 -eq 0) -or ($DetailedBSoD2 -eq 0) -or !$DetailedBSoD1 -or !$DetailedBSoD2)
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,11 @@ Function Invoke-WinUtilDarkMode {
|
||||
$Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize"
|
||||
Set-ItemProperty -Path $Path -Name AppsUseLightTheme -Value $DarkMoveValue
|
||||
Set-ItemProperty -Path $Path -Name SystemUsesLightTheme -Value $DarkMoveValue
|
||||
Invoke-WinUtilExplorerRefresh
|
||||
# Update Winutil Theme if the Theme Button shows the Icon for Auto
|
||||
if ($sync.ThemeButton.Content -eq [char]0xF08C) {
|
||||
Invoke-WinutilThemeChange -theme "Auto"
|
||||
}
|
||||
} catch [System.Security.SecurityException] {
|
||||
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
|
||||
} catch [System.Management.Automation.ItemNotFoundException] {
|
||||
|
33
functions/private/Invoke-WinUtilExplorerRefresh.ps1
Normal file
33
functions/private/Invoke-WinUtilExplorerRefresh.ps1
Normal file
@ -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))
|
||||
}
|
||||
}
|
@ -25,6 +25,56 @@ function Test-CompatibleImage() {
|
||||
}
|
||||
}
|
||||
|
||||
function Get-FidoLangFromCulture {
|
||||
|
||||
param (
|
||||
[Parameter(Mandatory, Position = 0)] [string] $langName
|
||||
)
|
||||
|
||||
switch -Wildcard ($langName)
|
||||
{
|
||||
"ar*" { return "Arabic" }
|
||||
"pt-BR" { return "Brazilian Portuguese" }
|
||||
"bg*" { return "Bulgarian" }
|
||||
{($_ -eq "zh-CH") -or ($_ -like "zh-Hans*") -or ($_ -eq "zh-SG") -or ($_ -eq "zh-CHS")} { return "Chinese (Simplified)" }
|
||||
{($_ -eq "zh") -or ($_ -eq "zh-Hant") -or ($_ -eq "zh-HK") -or ($_ -eq "zh-MO") -or ($_ -eq "zh-TW") -or ($_ -eq "zh-CHT")} { return "Chinese (Traditional)" }
|
||||
"hr*" { return "Croatian" }
|
||||
"cs*" { return "Czech" }
|
||||
"da*" { return "Danish" }
|
||||
"nl*" { return "Dutch" }
|
||||
"en-US" { return "English" }
|
||||
{($_ -like "en*") -and ($_ -ne "en-US")} { return "English International" }
|
||||
"et*" { return "Estonian" }
|
||||
"fi*" { return "Finnish" }
|
||||
{($_ -like "fr*") -and ($_ -ne "fr-CA")} { return "French" }
|
||||
"fr-CA" { return "French Canadian" }
|
||||
"de*" { return "German" }
|
||||
"el*" { return "Greek" }
|
||||
"he*" { return "Hebrew" }
|
||||
"hu*" { return "Hungarian" }
|
||||
"it*" { return "Italian" }
|
||||
"ja*" { return "Japanese" }
|
||||
"ko*" { return "Korean" }
|
||||
"lv*" { return "Latvian" }
|
||||
"lt*" { return "Lituanian" }
|
||||
"nb*" { return "Norwegian" }
|
||||
"pl*" { return "Polish" }
|
||||
{($_ -like "pt*") -and ($_ -ne "pt-BR")} { return "Portuguese" }
|
||||
"ro*" { return "Romanian" }
|
||||
"ru*" { return "Russian" }
|
||||
"sr-Latn*" { return "Serbian Latin" }
|
||||
"sk*" { return "Slovak" }
|
||||
"sl*" { return "Slovenian" }
|
||||
{($_ -like "es*") -and ($_ -ne "es-MX")} { return "Spanish" }
|
||||
"es-MX" { return "Spanish (Mexico)" }
|
||||
"sv*" { return "Swedish" }
|
||||
"th*" { return "Thai" }
|
||||
"tr*" { return "Turkish" }
|
||||
"uk*" { return "Ukrainian" }
|
||||
default { return "English" }
|
||||
}
|
||||
}
|
||||
|
||||
function Remove-Features() {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
@ -47,6 +97,7 @@ function Remove-Features() {
|
||||
$_.FeatureName -NotLike "*NetFx*" -AND
|
||||
$_.FeatureName -NotLike "*Media*" -AND
|
||||
$_.FeatureName -NotLike "*NFS*" -AND
|
||||
$_.FeatureName -NotLike "*SearchEngine*" -AND
|
||||
$_.State -ne "Disabled"
|
||||
}
|
||||
|
||||
@ -165,7 +216,8 @@ function Remove-ProvisionedPackages() {
|
||||
$_.PackageName -NotLike "*Paint*" -and
|
||||
$_.PackageName -NotLike "*Gaming*" -and
|
||||
$_.PackageName -NotLike "*Extension*" -and
|
||||
$_.PackageName -NotLike "*SecHealthUI*"
|
||||
$_.PackageName -NotLike "*SecHealthUI*" -and
|
||||
$_.PackageName -NotLike "*ScreenSketch*"
|
||||
}
|
||||
|
||||
$counter = 0
|
||||
|
180
functions/private/Invoke-WinutilThemeChange.ps1
Normal file
180
functions/private/Invoke-WinutilThemeChange.ps1
Normal file
@ -0,0 +1,180 @@
|
||||
function Invoke-WinutilThemeChange {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Toggles between light and dark themes for a Windows utility application.
|
||||
|
||||
.DESCRIPTION
|
||||
This function toggles the theme of the user interface between 'Light' and 'Dark' modes,
|
||||
modifying various UI elements such as colors, margins, corner radii, font families, etc.
|
||||
If the '-init' switch is used, it initializes the theme based on the system's current dark mode setting.
|
||||
|
||||
.PARAMETER init
|
||||
A switch parameter. If set to $true, the function initializes the theme based on the system’s current dark mode setting.
|
||||
|
||||
.EXAMPLE
|
||||
Invoke-WinutilThemeChange
|
||||
# Toggles the theme between 'Light' and 'Dark'.
|
||||
|
||||
.EXAMPLE
|
||||
Invoke-WinutilThemeChange -init
|
||||
# Initializes the theme based on the system's dark mode and applies the shared theme.
|
||||
#>
|
||||
param (
|
||||
[switch]$init = $false,
|
||||
[string]$theme
|
||||
)
|
||||
|
||||
function Set-WinutilTheme {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Applies the specified theme to the application's user interface.
|
||||
|
||||
.DESCRIPTION
|
||||
This internal function applies the given theme by setting the relevant properties
|
||||
like colors, font families, corner radii, etc., in the UI. It uses the
|
||||
'Set-ThemeResourceProperty' helper function to modify the application's resources.
|
||||
|
||||
.PARAMETER currentTheme
|
||||
The name of the theme to be applied. Common values are "Light", "Dark", or "shared".
|
||||
#>
|
||||
param (
|
||||
[string]$currentTheme
|
||||
)
|
||||
|
||||
function Set-ThemeResourceProperty {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Sets a specific UI property in the application's resources.
|
||||
|
||||
.DESCRIPTION
|
||||
This helper function sets a property (e.g., color, margin, corner radius) in the
|
||||
application's resources, based on the provided type and value. It includes
|
||||
error handling to manage potential issues while setting a property.
|
||||
|
||||
.PARAMETER Name
|
||||
The name of the resource property to modify (e.g., "MainBackgroundColor", "ButtonBackgroundMouseoverColor").
|
||||
|
||||
.PARAMETER Value
|
||||
The value to assign to the resource property (e.g., "#FFFFFF" for a color).
|
||||
|
||||
.PARAMETER Type
|
||||
The type of the resource, such as "ColorBrush", "CornerRadius", "GridLength", or "FontFamily".
|
||||
#>
|
||||
param($Name, $Value, $Type)
|
||||
try {
|
||||
# Set the resource property based on its type
|
||||
$sync.Form.Resources[$Name] = switch ($Type) {
|
||||
"ColorBrush" { [Windows.Media.SolidColorBrush]::new($Value) }
|
||||
"Color" {
|
||||
# Convert hex string to RGB values
|
||||
$hexColor = $Value.TrimStart("#")
|
||||
$r = [Convert]::ToInt32($hexColor.Substring(0,2), 16)
|
||||
$g = [Convert]::ToInt32($hexColor.Substring(2,2), 16)
|
||||
$b = [Convert]::ToInt32($hexColor.Substring(4,2), 16)
|
||||
[Windows.Media.Color]::FromRgb($r, $g, $b)
|
||||
}
|
||||
"CornerRadius" { [System.Windows.CornerRadius]::new($Value) }
|
||||
"GridLength" { [System.Windows.GridLength]::new($Value) }
|
||||
"Thickness" {
|
||||
# Parse the Thickness value (supports 1, 2, or 4 inputs)
|
||||
$values = $Value -split ","
|
||||
switch ($values.Count) {
|
||||
1 { [System.Windows.Thickness]::new([double]$values[0]) }
|
||||
2 { [System.Windows.Thickness]::new([double]$values[0], [double]$values[1]) }
|
||||
4 { [System.Windows.Thickness]::new([double]$values[0], [double]$values[1], [double]$values[2], [double]$values[3]) }
|
||||
}
|
||||
}
|
||||
"FontFamily" { [Windows.Media.FontFamily]::new($Value) }
|
||||
"Double" { [double]$Value }
|
||||
default { $Value }
|
||||
}
|
||||
}
|
||||
catch {
|
||||
# Log a warning if there's an issue setting the property
|
||||
Write-Warning "Failed to set property $($Name): $_"
|
||||
}
|
||||
}
|
||||
|
||||
# Retrieve all theme properties from the theme configuration
|
||||
$themeProperties = $sync.configs.themes.$currentTheme.PSObject.Properties
|
||||
foreach ($_ in $themeProperties) {
|
||||
# Apply properties that deal with colors
|
||||
if ($_.Name -like "*color*") {
|
||||
Set-ThemeResourceProperty -Name $_.Name -Value $_.Value -Type "ColorBrush"
|
||||
# For certain color properties, also set complementary values (e.g., BorderColor -> CBorderColor) This is required because e.g DropShadowEffect requires a <Color> and not a <SolidColorBrush> object
|
||||
if ($_.Name -in @("BorderColor", "ButtonBackgroundMouseoverColor")) {
|
||||
Set-ThemeResourceProperty -Name "C$($_.Name)" -Value $_.Value -Type "Color"
|
||||
}
|
||||
}
|
||||
# Apply corner radius properties
|
||||
elseif ($_.Name -like "*Radius*") {
|
||||
Set-ThemeResourceProperty -Name $_.Name -Value $_.Value -Type "CornerRadius"
|
||||
}
|
||||
# Apply row height properties
|
||||
elseif ($_.Name -like "*RowHeight*") {
|
||||
Set-ThemeResourceProperty -Name $_.Name -Value $_.Value -Type "GridLength"
|
||||
}
|
||||
# Apply thickness or margin properties
|
||||
elseif (($_.Name -like "*Thickness*") -or ($_.Name -like "*margin")) {
|
||||
Set-ThemeResourceProperty -Name $_.Name -Value $_.Value -Type "Thickness"
|
||||
}
|
||||
# Apply font family properties
|
||||
elseif ($_.Name -like "*FontFamily*") {
|
||||
Set-ThemeResourceProperty -Name $_.Name -Value $_.Value -Type "FontFamily"
|
||||
}
|
||||
# Apply any other properties as doubles (numerical values)
|
||||
else {
|
||||
Set-ThemeResourceProperty -Name $_.Name -Value $_.Value -Type "Double"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$LightPreferencePath = "$env:LOCALAPPDATA\winutil\LightTheme.ini"
|
||||
$DarkPreferencePath = "$env:LOCALAPPDATA\winutil\DarkTheme.ini"
|
||||
|
||||
if ($init) {
|
||||
Set-WinutilTheme -currentTheme "shared"
|
||||
if (Test-Path $LightPreferencePath) {
|
||||
$theme = "Light"
|
||||
}
|
||||
elseif (Test-Path $DarkPreferencePath) {
|
||||
$theme = "Dark"
|
||||
}
|
||||
else {
|
||||
$theme = "Auto"
|
||||
}
|
||||
}
|
||||
|
||||
switch ($theme) {
|
||||
"Auto" {
|
||||
$systemUsesDarkMode = Get-WinUtilToggleStatus WPFToggleDarkMode
|
||||
if ($systemUsesDarkMode) {
|
||||
Set-WinutilTheme -currentTheme "Dark"
|
||||
}
|
||||
else{
|
||||
Set-WinutilTheme -currentTheme "Light"
|
||||
}
|
||||
|
||||
|
||||
$themeButtonIcon = [char]0xF08C
|
||||
Remove-Item $LightPreferencePath -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item $DarkPreferencePath -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
"Dark" {
|
||||
Set-WinutilTheme -currentTheme $theme
|
||||
$themeButtonIcon = [char]0xE708
|
||||
$null = New-Item $DarkPreferencePath -Force
|
||||
Remove-Item $LightPreferencePath -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
"Light" {
|
||||
Set-WinutilTheme -currentTheme $theme
|
||||
$themeButtonIcon = [char]0xE706
|
||||
$null = New-Item $LightPreferencePath -Force
|
||||
Remove-Item $DarkPreferencePath -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
|
||||
# Update the theme selector button with the appropriate icon
|
||||
$ThemeButton = $sync.Form.FindName("ThemeButton")
|
||||
$ThemeButton.Content = [string]$themeButtonIcon
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
function Set-WinUtilUITheme {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Sets the theme of the XAML file
|
||||
|
||||
.PARAMETER inputXML
|
||||
A string representing the XAML object to modify
|
||||
|
||||
.PARAMETER customThemeName
|
||||
The name of the custom theme to set the XAML to. Defaults to 'matrix'
|
||||
|
||||
.PARAMETER defaultThemeName
|
||||
The name of the default theme to use when setting the XAML. Defaults to '_default'
|
||||
|
||||
.EXAMPLE
|
||||
$returnVal = Set-WinUtilUITheme -inputXAML $inputXAML
|
||||
if ($returnVal[0] -eq "") {
|
||||
Write-Host "Failed to process inputXML"
|
||||
} else {
|
||||
$inputXML = $returnVal[0]
|
||||
}
|
||||
# to know which theme this function has used, access the second item in returned value.
|
||||
Write-Host "Theme used in processing: $($returnVal[1])"
|
||||
#>
|
||||
|
||||
param (
|
||||
[Parameter(Mandatory, position=0)]
|
||||
[string]$inputXML,
|
||||
|
||||
[Parameter(position=1)]
|
||||
[string]$customThemeName = 'matrix',
|
||||
|
||||
[Parameter(position=2)]
|
||||
[string]$defaultThemeName = '_default'
|
||||
)
|
||||
|
||||
try {
|
||||
# Note:
|
||||
# Reason behind not caching the '$sync.configs.themes` object into a variable,
|
||||
# because this code can modify the themes object.. meaning it's better to access it
|
||||
# using the more verbose way, rather than introduce possible bugs into the code, just for the sake of readability.
|
||||
#
|
||||
if (-NOT $sync.configs.themes) {
|
||||
throw [GenericException]::new("[Set-WinUtilTheme] Did not find 'config.themes' inside `$sync variable.")
|
||||
}
|
||||
|
||||
if (-NOT $sync.configs.themes.$defaultThemeName) {
|
||||
throw [GenericException]::new("[Set-WinUtilTheme] Did not find '$defaultThemeName' theme in the themes config file.")
|
||||
}
|
||||
|
||||
$themeToUse = $customThemeName
|
||||
if ($sync.configs.themes.$themeToUse) {
|
||||
# Loop through every default theme option, and modify the custom theme in $sync variable,
|
||||
# so that it has full options available for other functions to use.
|
||||
foreach ($option in $sync.configs.themes.$defaultThemeName.PSObject.Properties) {
|
||||
$optionName = $option.Name
|
||||
$optionValue = $option.Value
|
||||
if (-NOT $sync.configs.themes.$themeToUse.$optionName) {
|
||||
$sync.configs.themes.$themeToUse | Add-Member -MemberType NoteProperty -Name $optionName -Value $optionValue
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Write-Debug "[Set-WinUtilTheme] Theme '$customThemeName' was not found, using '$defaultThemeName' instead."
|
||||
$themeToUse = $defaultThemeName
|
||||
}
|
||||
|
||||
foreach ($property in $sync.configs.themes.$themeToUse.PSObject.Properties) {
|
||||
$key = $property.Name
|
||||
$value = $property.Value
|
||||
# Add curly braces around the key
|
||||
$formattedKey = "{$key}"
|
||||
# Replace the key with the value in the input XML
|
||||
$inputXML = $inputXML.Replace($formattedKey, $value)
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Host "[Set-WinUtilTheme] Unable to apply theme" -ForegroundColor Red
|
||||
Write-Host "$($psitem.Exception.Message)" -ForegroundColor Red
|
||||
$inputXML = "" # Make inputXML equal an empty string, indicating something went wrong to the function caller.
|
||||
}
|
||||
|
||||
return @($inputXML, $themeToUse);
|
||||
}
|
@ -33,25 +33,25 @@ function Show-CustomDialog {
|
||||
#>
|
||||
param(
|
||||
[string]$Message,
|
||||
[int]$Width = 300,
|
||||
[int]$Height = 200,
|
||||
[int]$FontSize = 10,
|
||||
[int]$HeaderFontSize = 14,
|
||||
[int]$IconSize = 25,
|
||||
[int]$Width = $sync.Form.Resources.CustomDialogWidth,
|
||||
[int]$Height = $sync.Form.Resources.CustomDialogHeight,
|
||||
[int]$FontSize = $sync.Form.Resources.CustomDialogFontSize,
|
||||
[int]$HeaderFontSize = $sync.Form.Resources.CustomDialogFontSizeHeader,
|
||||
[int]$IconSize = $sync.Form.Resources.CustomDialogLogoSize,
|
||||
[bool]$EnableScroll = $false
|
||||
)
|
||||
|
||||
Add-Type -AssemblyName PresentationFramework
|
||||
|
||||
# Define theme colors
|
||||
$foregroundColor = $sync.configs.themes.$ctttheme.MainForegroundColor
|
||||
$backgroundColor = $sync.configs.themes.$ctttheme.MainBackgroundColor
|
||||
$foregroundColor = $sync.Form.Resources.MainForegroundColor
|
||||
$backgroundColor = $sync.Form.Resources.MainBackgroundColor
|
||||
$font = New-Object Windows.Media.FontFamily("Consolas")
|
||||
$borderColor = $sync.configs.themes.$ctttheme.BorderColor # ButtonInstallBackgroundColor
|
||||
$buttonBackgroundColor = $sync.configs.themes.$ctttheme.ButtonInstallBackgroundColor
|
||||
$buttonForegroundColor = $sync.configs.themes.$ctttheme.ButtonInstallForegroundColor
|
||||
$borderColor = $sync.Form.Resources.BorderColor # ButtonInstallBackgroundColor
|
||||
$buttonBackgroundColor = $sync.Form.Resources.ButtonInstallBackgroundColor
|
||||
$buttonForegroundColor = $sync.Form.Resources.ButtonInstallForegroundColor
|
||||
$shadowColor = [Windows.Media.ColorConverter]::ConvertFromString("#AAAAAAAA")
|
||||
$logocolor = $sync.configs.themes.$ctttheme.LabelboxForegroundColor
|
||||
$logocolor = $sync.Form.Resources.LabelboxForegroundColor
|
||||
|
||||
# Create a custom dialog window
|
||||
$dialog = New-Object Windows.Window
|
||||
@ -162,7 +162,7 @@ function Show-CustomDialog {
|
||||
$hyperlink.NavigateUri = New-Object System.Uri($match.Groups[1].Value)
|
||||
$hyperlink.Inlines.Add($match.Groups[2].Value)
|
||||
$hyperlink.TextDecorations = [Windows.TextDecorations]::None # Remove underline
|
||||
$hyperlink.Foreground = $sync.configs.themes.$ctttheme.LinkForegroundColor
|
||||
$hyperlink.Foreground = $sync.Form.Resources.LinkForegroundColor
|
||||
|
||||
$hyperlink.Add_Click({
|
||||
param($sender, $args)
|
||||
@ -170,11 +170,11 @@ function Show-CustomDialog {
|
||||
})
|
||||
$hyperlink.Add_MouseEnter({
|
||||
param($sender, $args)
|
||||
$sender.Foreground = $sync.configs.themes.$ctttheme.LinkHoverForegroundColor
|
||||
$sender.Foreground = $sync.Form.Resources.LinkHoverForegroundColor
|
||||
})
|
||||
$hyperlink.Add_MouseLeave({
|
||||
param($sender, $args)
|
||||
$sender.Foreground = $sync.configs.themes.$ctttheme.LinkForegroundColor
|
||||
$sender.Foreground = $sync.Form.Resources.LinkForegroundColor
|
||||
})
|
||||
|
||||
$messageTextBlock.Inlines.Add($hyperlink)
|
||||
|
@ -19,7 +19,6 @@ function Invoke-WPFButton {
|
||||
}
|
||||
|
||||
Switch -Wildcard ($Button) {
|
||||
|
||||
"WPFTab?BT" {Invoke-WPFTab $Button}
|
||||
"WPFInstall" {Invoke-WPFInstall}
|
||||
"WPFUninstall" {Invoke-WPFUnInstall}
|
||||
|
@ -62,17 +62,32 @@ function Invoke-WPFGetIso {
|
||||
}
|
||||
}
|
||||
|
||||
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
|
||||
$openFileDialog = New-Object System.Windows.Forms.OpenFileDialog
|
||||
$openFileDialog.initialDirectory = $initialDirectory
|
||||
$openFileDialog.filter = "ISO files (*.iso)| *.iso"
|
||||
$openFileDialog.ShowDialog() | Out-Null
|
||||
$filePath = $openFileDialog.FileName
|
||||
if ($sync["ISOmanual"].IsChecked) {
|
||||
# Open file dialog to let user choose the ISO file
|
||||
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
|
||||
$openFileDialog = New-Object System.Windows.Forms.OpenFileDialog
|
||||
$openFileDialog.initialDirectory = $initialDirectory
|
||||
$openFileDialog.filter = "ISO files (*.iso)| *.iso"
|
||||
$openFileDialog.ShowDialog() | Out-Null
|
||||
$filePath = $openFileDialog.FileName
|
||||
|
||||
if ([string]::IsNullOrEmpty($filePath)) {
|
||||
Write-Host "No ISO is chosen"
|
||||
$sync.BusyMessage.Visibility="Hidden"
|
||||
return
|
||||
if ([string]::IsNullOrEmpty($filePath)) {
|
||||
Write-Host "No ISO is chosen"
|
||||
$sync.BusyMessage.Visibility="Hidden"
|
||||
return
|
||||
}
|
||||
} elseif ($sync["ISOdownloader"].IsChecked) {
|
||||
# Auto download newest ISO
|
||||
# Credit: https://github.com/pbatard/Fido
|
||||
$fidopath = "$env:temp\Fido.ps1"
|
||||
$originalLocation = Get-Location
|
||||
|
||||
Invoke-WebRequest "https://github.com/pbatard/Fido/raw/master/Fido.ps1" -OutFile $fidopath
|
||||
|
||||
Set-Location -Path $env:temp
|
||||
& $fidopath -Win 'Windows 11' -Rel $sync["ISORelease"].SelectedItem -Arch "x64" -Lang $sync["ISOLanguage"].SelectedItem -Ed "Windows 11 Home/Pro/Edu"
|
||||
Set-Location $originalLocation
|
||||
$filePath = Get-ChildItem -Path "$env:temp" -Filter "Win11*.iso" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
|
||||
}
|
||||
|
||||
Write-Host "File path $($filePath)"
|
||||
|
@ -27,7 +27,7 @@ function Invoke-WPFUIElements {
|
||||
|
||||
$window = $sync["Form"]
|
||||
|
||||
$theme = $sync.configs.themes.$ctttheme
|
||||
$theme = $sync.Form.Resources
|
||||
$borderstyle = $window.FindResource("BorderStyle")
|
||||
$HoverTextBlockStyle = $window.FindResource("HoverTextBlockStyle")
|
||||
$ColorfulToggleSwitchStyle = $window.FindResource("ColorfulToggleSwitchStyle")
|
||||
@ -186,7 +186,7 @@ function Invoke-WPFUIElements {
|
||||
$label.ToolTip = $entryInfo.Description
|
||||
$label.HorizontalAlignment = "Left"
|
||||
$label.FontSize = $theme.FontSize
|
||||
$label.Foreground = $theme.MainForegroundColor
|
||||
$label.SetResourceReference([Windows.Controls.Control]::ForegroundProperty, "MainForegroundColor")
|
||||
$dockPanel.Children.Add($label) | Out-Null
|
||||
$stackPanel.Children.Add($dockPanel) | Out-Null
|
||||
|
||||
@ -207,14 +207,14 @@ function Invoke-WPFUIElements {
|
||||
$toggleButton.HorizontalAlignment = "Left"
|
||||
$toggleButton.Height = $theme.TabButtonHeight
|
||||
$toggleButton.Width = $theme.TabButtonWidth
|
||||
$toggleButton.Background = $theme.ButtonInstallBackgroundColor
|
||||
$toggleButton.Foreground = [Windows.Media.Brushes]::White
|
||||
$toggleButton.SetResourceReference([Windows.Controls.Control]::BackgroundProperty, "ButtonInstallBackgroundColor")
|
||||
$toggleButton.SetResourceReference([Windows.Controls.Control]::ForegroundProperty, "MainForegroundColor")
|
||||
$toggleButton.FontWeight = [Windows.FontWeights]::Bold
|
||||
|
||||
$textBlock = New-Object Windows.Controls.TextBlock
|
||||
$textBlock.FontSize = $theme.TabButtonFontSize
|
||||
$textBlock.Background = [Windows.Media.Brushes]::Transparent
|
||||
$textBlock.Foreground = $theme.ButtonInstallForegroundColor
|
||||
$textBlock.SetResourceReference([Windows.Controls.Control]::ForegroundProperty, "ButtonInstallForegroundColor")
|
||||
|
||||
$underline = New-Object Windows.Documents.Underline
|
||||
$underline.Inlines.Add($entryInfo.name -replace "(.).*", "`$1")
|
||||
|
@ -50,14 +50,14 @@ Function Invoke-WPFUltimatePerformance {
|
||||
|
||||
} elseif ($State -eq "Disable") {
|
||||
# Check if the Ultimate Performance plan is installed by GUID
|
||||
$installedPlan = powercfg -list | Select-String -Pattern $ultimateGUID
|
||||
$installedPlan = (powercfg -list | Select-String -Pattern "ChrisTitus - Ultimate Power Plan").Line.Split()[3]
|
||||
|
||||
if ($installedPlan) {
|
||||
# Extract the GUID of the installed Ultimate Performance plan
|
||||
$ultimatePlanGUID = $installedPlan.Line.Split()[3]
|
||||
|
||||
# Set a different power plan as active before deleting the Ultimate Performance plan
|
||||
$balancedPlanGUID = (powercfg -list | Select-String -Pattern "Balanced").Line.Split()[3]
|
||||
$balancedPlanGUID = 381b4222-f694-41f0-9685-ff5bb260df2e
|
||||
powercfg -setactive $balancedPlanGUID
|
||||
|
||||
# Delete the Ultimate Performance plan by GUID
|
||||
|
171
scripts/main.ps1
171
scripts/main.ps1
@ -52,29 +52,6 @@ $sync.runspace.Open()
|
||||
|
||||
$inputXML = $inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^<Win.*', '<Window'
|
||||
|
||||
$defaulttheme = '_default'
|
||||
if ((Get-WinUtilToggleStatus WPFToggleDarkMode) -eq $True) {
|
||||
if (Invoke-WinUtilGPU -eq $True) {
|
||||
$ctttheme = 'Matrix'
|
||||
} else {
|
||||
$ctttheme = 'Dark'
|
||||
}
|
||||
} else {
|
||||
$ctttheme = 'Classic'
|
||||
}
|
||||
|
||||
$returnVal = Set-WinUtilUITheme -inputXML $inputXML -customThemeName $ctttheme -defaultThemeName $defaulttheme
|
||||
if ($returnVal[0] -eq "") {
|
||||
Write-Host "Failed to statically apply theming to xaml content using Set-WinUtilTheme, please check previous Error/Warning messages." -ForegroundColor Red
|
||||
Write-Host "Quitting winutil..." -ForegroundColor Red
|
||||
$sync.runspace.Dispose()
|
||||
$sync.runspace.Close()
|
||||
[System.GC]::Collect()
|
||||
exit 1
|
||||
}
|
||||
$inputXML = $returnVal[0]
|
||||
$ctttheme = $returnVal[1]
|
||||
|
||||
[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
|
||||
[xml]$XAML = $inputXML
|
||||
|
||||
@ -104,6 +81,35 @@ if (-NOT ($readerOperationSuccessful)) {
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Setup the Window to follow listen for windows Theme Change events and update the winutil theme
|
||||
# throttle logic needed, because windows seems to send more than one theme change event per change
|
||||
$lastThemeChangeTime = [datetime]::MinValue
|
||||
$debounceInterval = [timespan]::FromSeconds(2)
|
||||
$sync.Form.Add_Loaded({
|
||||
$interopHelper = New-Object System.Windows.Interop.WindowInteropHelper $sync.Form
|
||||
$hwndSource = [System.Windows.Interop.HwndSource]::FromHwnd($interopHelper.Handle)
|
||||
$hwndSource.AddHook({
|
||||
param (
|
||||
[System.IntPtr]$hwnd,
|
||||
[int]$msg,
|
||||
[System.IntPtr]$wParam,
|
||||
[System.IntPtr]$lParam,
|
||||
[ref]$handled
|
||||
)
|
||||
# Check for the Event WM_SETTINGCHANGE (0x1001A) and validate that Button shows the icon for "Auto" => [char]0xF08C
|
||||
if (($msg -eq 0x001A) -and $sync.ThemeButton.Content -eq [char]0xF08C) {
|
||||
$currentTime = [datetime]::Now
|
||||
if ($currentTime - $lastThemeChangeTime -gt $debounceInterval) {
|
||||
Invoke-WinutilThemeChange -theme "Auto"
|
||||
$script:lastThemeChangeTime = $currentTime
|
||||
$handled = $true
|
||||
}
|
||||
}
|
||||
return 0
|
||||
})
|
||||
})
|
||||
|
||||
Invoke-WinutilThemeChange -init $true
|
||||
# Load the configuration files
|
||||
#Invoke-WPFUIElements -configVariable $sync.configs.nav -targetGridName "WPFMainGrid"
|
||||
Invoke-WPFUIElements -configVariable $sync.configs.applications -targetGridName "appspanel" -columncount 5
|
||||
@ -248,24 +254,34 @@ $commonKeyEvents = {
|
||||
$sync["Form"].Add_PreViewKeyDown($commonKeyEvents)
|
||||
|
||||
$sync["Form"].Add_MouseLeftButtonDown({
|
||||
if ($sync["SettingsPopup"].IsOpen) {
|
||||
$sync["SettingsPopup"].IsOpen = $false
|
||||
}
|
||||
# Hide Settings and Theme Popup on click anywhere else
|
||||
if ($sync.SettingsButton.IsOpen -or
|
||||
$sync.ThemePopup.IsOpen) {
|
||||
$sync.SettingsPopup.IsOpen = $false
|
||||
$sync.ThemePopup.IsOpen = $false
|
||||
}
|
||||
$sync["Form"].DragMove()
|
||||
})
|
||||
|
||||
$sync["Form"].Add_MouseDoubleClick({
|
||||
if ($sync["Form"].WindowState -eq [Windows.WindowState]::Normal) {
|
||||
$sync["Form"].WindowState = [Windows.WindowState]::Maximized;
|
||||
} else {
|
||||
$sync["Form"].WindowState = [Windows.WindowState]::Normal;
|
||||
if ($_.OriginalSource -is [System.Windows.Controls.Grid] -or
|
||||
$_.OriginalSource -is [System.Windows.Controls.StackPanel]) {
|
||||
if ($sync["Form"].WindowState -eq [Windows.WindowState]::Normal) {
|
||||
$sync["Form"].WindowState = [Windows.WindowState]::Maximized
|
||||
}
|
||||
else{
|
||||
$sync["Form"].WindowState = [Windows.WindowState]::Normal
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
$sync["Form"].Add_Deactivated({
|
||||
Write-Debug "WinUtil lost focus"
|
||||
if ($sync["SettingsPopup"].IsOpen) {
|
||||
$sync["SettingsPopup"].IsOpen = $false
|
||||
# Hide Settings and Theme Popup on Winutil Focus Loss
|
||||
if ($sync.SettingsButton.IsOpen -or
|
||||
$sync.ThemePopup.IsOpen) {
|
||||
$sync.SettingsPopup.IsOpen = $false
|
||||
$sync.ThemePopup.IsOpen = $false
|
||||
}
|
||||
})
|
||||
|
||||
@ -383,6 +399,37 @@ Add-Type @"
|
||||
|
||||
})
|
||||
|
||||
# Add event handlers for the RadioButtons
|
||||
$sync["ISOdownloader"].add_Checked({
|
||||
$sync["ISORelease"].Visibility = [System.Windows.Visibility]::Visible
|
||||
$sync["ISOLanguage"].Visibility = [System.Windows.Visibility]::Visible
|
||||
})
|
||||
|
||||
$sync["ISOmanual"].add_Checked({
|
||||
$sync["ISORelease"].Visibility = [System.Windows.Visibility]::Collapsed
|
||||
$sync["ISOLanguage"].Visibility = [System.Windows.Visibility]::Collapsed
|
||||
})
|
||||
|
||||
$sync["ISORelease"].Items.Add("23H2") | Out-Null
|
||||
$sync["ISORelease"].Items.Add("22H2") | Out-Null
|
||||
$sync["ISORelease"].Items.Add("21H2") | Out-Null
|
||||
$sync["ISORelease"].SelectedItem = "23H2"
|
||||
|
||||
$currentCulture = Get-FidoLangFromCulture -langName (Get-Culture).Name
|
||||
|
||||
$sync["ISOLanguage"].Items.Add($currentCulture) | Out-Null
|
||||
if ($currentCulture -ne "English International") {
|
||||
$sync["ISOLanguage"].Items.Add("English International") | Out-Null
|
||||
}
|
||||
if ($currentCulture -ne "English") {
|
||||
$sync["ISOLanguage"].Items.Add("English") | Out-Null
|
||||
}
|
||||
if ($sync["ISOLanguage"].Items.Count -eq 1) {
|
||||
$sync["ISOLanguage"].IsEnabled = $false
|
||||
}
|
||||
$sync["ISOLanguage"].SelectedItem = $currentCulture
|
||||
|
||||
|
||||
# Load Checkboxes and Labels outside of the Filter function only once on startup for performance reasons
|
||||
$filter = Get-WinUtilVariables -Type CheckBox
|
||||
$CheckBoxes = ($sync.GetEnumerator()).where{ $psitem.Key -in $filter }
|
||||
@ -405,8 +452,8 @@ $sync["SearchBar"].Add_TextChanged({
|
||||
$textToSearch = $sync.SearchBar.Text.ToLower()
|
||||
|
||||
foreach ($CheckBox in $CheckBoxes) {
|
||||
# Check if the checkbox is null or if it doesn't have content
|
||||
if ($CheckBox -eq $null -or $CheckBox.Value -eq $null -or $CheckBox.Value.Content -eq $null) {
|
||||
# Skip if the checkbox is null, it doesn't have content or it is the prefer Choco checkbox
|
||||
if ($CheckBox -eq $null -or $CheckBox.Value -eq $null -or $CheckBox.Value.Content -eq $null -or $CheckBox.Name -eq "WPFpreferChocolatey") {
|
||||
continue
|
||||
}
|
||||
|
||||
@ -478,15 +525,47 @@ Set-WinUtilTaskbaritem -overlay "logo"
|
||||
$sync["Form"].Add_Activated({
|
||||
Set-WinUtilTaskbaritem -overlay "logo"
|
||||
})
|
||||
# Define event handler for ThemeButton click
|
||||
$sync["ThemeButton"].Add_Click({
|
||||
if ($sync.ThemePopup.IsOpen) {
|
||||
$sync.ThemePopup.IsOpen = $false
|
||||
}
|
||||
else{
|
||||
$sync.ThemePopup.IsOpen = $true
|
||||
}
|
||||
$sync.SettingsPopup.IsOpen = $false
|
||||
})
|
||||
|
||||
# Define event handlers for menu items
|
||||
$sync["AutoThemeMenuItem"].Add_Click({
|
||||
$sync.ThemePopup.IsOpen = $false
|
||||
Invoke-WinutilThemeChange -theme "Auto"
|
||||
$_.Handled = $false
|
||||
})
|
||||
# Define event handlers for menu items
|
||||
$sync["DarkThemeMenuItem"].Add_Click({
|
||||
$sync.ThemePopup.IsOpen = $false
|
||||
Invoke-WinutilThemeChange -theme "Dark"
|
||||
$_.Handled = $false
|
||||
})
|
||||
# Define event handlers for menu items
|
||||
$sync["LightThemeMenuItem"].Add_Click({
|
||||
$sync.ThemePopup.IsOpen = $false
|
||||
Invoke-WinutilThemeChange -theme "Light"
|
||||
$_.Handled = $false
|
||||
})
|
||||
|
||||
|
||||
# Define event handler for button click
|
||||
$sync["SettingsButton"].Add_Click({
|
||||
Write-Debug "SettingsButton clicked"
|
||||
if ($sync["SettingsPopup"].IsOpen) {
|
||||
$sync["SettingsPopup"].IsOpen = $false
|
||||
} else {
|
||||
$sync["SettingsPopup"].IsOpen = $true
|
||||
if ($sync.SettingsPopup.IsOpen) {
|
||||
$sync.SettingsPopup.IsOpen = $false
|
||||
}
|
||||
else{
|
||||
$sync.SettingsPopup.IsOpen = $true
|
||||
}
|
||||
$sync.ThemePopup.IsOpen = $false
|
||||
$_.Handled = $false
|
||||
})
|
||||
|
||||
@ -518,12 +597,8 @@ MicroWin : <a href="https://github.com/KonTy">@KonTy</a>
|
||||
GitHub : <a href="https://github.com/ChrisTitusTech/winutil">ChrisTitusTech/winutil</a>
|
||||
Version : <a href="https://github.com/ChrisTitusTech/winutil/releases/tag/$($sync.version)">$($sync.version)</a>
|
||||
"@
|
||||
$FontSize = $sync.configs.themes.$ctttheme.CustomDialogFontSize
|
||||
$HeaderFontSize = $sync.configs.themes.$ctttheme.CustomDialogFontSizeHeader
|
||||
$LogoSize = $sync.configs.themes.$ctttheme.CustomDialogLogoSize
|
||||
$Width = $sync.configs.themes.$ctttheme.CustomDialogWidth
|
||||
$Height = $sync.configs.themes.$ctttheme.CustomDialogHeight
|
||||
Show-CustomDialog -Message $authorInfo -Width $Width -Height $Height -FontSize $FontSize -HeaderFontSize $HeaderFontSize -LogoSize $LogoSize
|
||||
|
||||
Show-CustomDialog -Message $authorInfo -LogoSize $LogoSize
|
||||
})
|
||||
|
||||
$sync["SponsorMenuItem"].Add_Click({
|
||||
@ -544,12 +619,8 @@ $sync["SponsorMenuItem"].Add_Click({
|
||||
$authorInfo += "An error occurred while fetching or processing the sponsors: $_`n"
|
||||
}
|
||||
|
||||
$FontSize = $sync.configs.themes.$ctttheme.CustomDialogFontSize
|
||||
$HeaderFontSize = $sync.configs.themes.$ctttheme.CustomDialogFontSizeHeader
|
||||
$LogoSize = $sync.configs.themes.$ctttheme.CustomDialogLogoSize
|
||||
$Width = $sync.configs.themes.$ctttheme.CustomDialogWidth
|
||||
$Height = $sync.configs.themes.$ctttheme.CustomDialogHeight
|
||||
Show-CustomDialog -Message $authorInfo -Width $Width -Height $Height -FontSize $FontSize -HeaderFontSize $HeaderFontSize -LogoSize $LogoSize -EnableScroll $true
|
||||
Show-CustomDialog -Message $authorInfo -EnableScroll $true
|
||||
})
|
||||
|
||||
$sync["Form"].ShowDialog() | out-null
|
||||
Stop-Transcript
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user