Skip to content

Commit

Permalink
convert numlock on startup checkboxs into toggle button
Browse files Browse the repository at this point in the history
  • Loading branch information
padsalatushal committed Nov 7, 2023
1 parent 614f6e4 commit 81fb832
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 64 deletions.
6 changes: 2 additions & 4 deletions config/preset.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
"WPFEssTweaksStorage",
"WPFEssTweaksTele",
"WPFEssTweaksWifi",
"WPFMiscTweaksPower",
"WPFMiscTweaksNum"
"WPFMiscTweaksPower"
],
"laptop": [
"WPFEssTweaksAH",
Expand All @@ -23,8 +22,7 @@
"WPFEssTweaksStorage",
"WPFEssTweaksTele",
"WPFEssTweaksWifi",
"WPFMiscTweaksLapPower",
"WPFMiscTweaksLapNum"
"WPFMiscTweaksLapPower"
],
"minimal": [
"WPFEssTweaksHome",
Expand Down
22 changes: 0 additions & 22 deletions config/tweaks.json
Original file line number Diff line number Diff line change
Expand Up @@ -2163,28 +2163,6 @@
"
]
},
"WPFMiscTweaksLapNum": {
"Registry": [
{
"Path": "HKU:\\.DEFAULT\\Control Panel\\Keyboard",
"OriginalValue": "1",
"Name": "InitialKeyboardIndicators",
"Value": "0",
"Type": "DWord"
}
]
},
"WPFMiscTweaksNum": {
"Registry": [
{
"Path": "HKU:\\.DEFAULT\\Control Panel\\Keyboard",
"OriginalValue": "1",
"Name": "InitialKeyboardIndicators",
"Value": "80000002",
"Type": "DWord"
}
]
},
"WPFEssTweaksRemoveEdge": {
"InvokeScript": [
"
Expand Down
9 changes: 9 additions & 0 deletions functions/private/Get-WinUtilToggleStatus.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,13 @@ Function Get-WinUtilToggleStatus {
return $true
}
}
if($ToggleSwitch -eq "WPFToggleNumLock"){
$numlockvalue = (Get-ItemProperty -path 'HKCU:\Control Panel\Keyboard').InitialKeyboardIndicators
if($numlockvalue -eq 2){
return $true
}
else{
return $false
}
}
}
31 changes: 31 additions & 0 deletions functions/private/Invoke-WinUtilNumLock.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
function Invoke-WinUtilNumLock {
<#
.SYNOPSIS
Disables/Enables NumLock on startup
.PARAMETER Enabled
Indicates whether to enable or disable Numlock on startup
#>
Param($Enabled)
Try{
if ($Enabled -eq $false){
Write-Host "Enabling Numlock on startup"
$value = 2
}
else {
Write-Host "Disabling Numlock on startup"
$value = 0
}
$Path = "HKCU:\Control Panel\Keyboard"
Set-ItemProperty -Path $Path -Name InitialKeyboardIndicators -Value $value
}
Catch [System.Security.SecurityException] {
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
}
Catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning $psitem.Exception.ErrorRecord
}
Catch{
Write-Warning "Unable to set $Name due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}
}
1 change: 0 additions & 1 deletion functions/public/Invoke-WPFButton.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ function Invoke-WPFButton {
"WPFtweaksbutton" {Invoke-WPFtweaksbutton}
"WPFAddUltPerf" {Invoke-WPFUltimatePerformance -State "Enabled"}
"WPFRemoveUltPerf" {Invoke-WPFUltimatePerformance -State "Disabled"}
"WPFToggleDarkMode" {Invoke-WPFDarkMode -DarkMoveEnabled $(Get-WinUtilDarkMode)}
"WPFundoall" {Invoke-WPFundoall}
"WPFFeatureInstall" {Invoke-WPFFeatureInstall}
"WPFPanelDISM" {Invoke-WPFPanelDISM}
Expand Down
2 changes: 1 addition & 1 deletion functions/public/Invoke-WPFToggle.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ function Invoke-WPFToggle {

"WPFToggleDarkMode" {Invoke-WinUtilDarkMode -DarkMoveEnabled $(Get-WinUtilToggleStatus WPFToggleDarkMode)}
"WPFToggleBingSearch" {Invoke-WinUtilBingSearch $(Get-WinUtilToggleStatus WPFToggleBingSearch)}

"WPFToggleNumLock" {Invoke-WinUtilNumLock $(Get-WinUtilToggleStatus WPFToggleNumLock)}
}
}
84 changes: 51 additions & 33 deletions winutil.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Author : Chris Titus @christitustech
Runspace Author: @DeveloperDurp
GitHub : https://github.com/ChrisTitusTech
Version : 23.10.31
Version : 23.11.07
#>

Start-Transcript $ENV:TEMP\Winutil.log -Append
Expand All @@ -21,7 +21,7 @@ Add-Type -AssemblyName System.Windows.Forms
# Variable to sync between runspaces
$sync = [Hashtable]::Synchronized(@{})
$sync.PSScriptRoot = $PSScriptRoot
$sync.version = "23.10.31"
$sync.version = "23.11.07"
$sync.configs = @{}
$sync.ProcessRunning = $false

Expand Down Expand Up @@ -196,6 +196,15 @@ Function Get-WinUtilToggleStatus {
return $true
}
}
if($ToggleSwitch -eq "WPFToggleNumLock"){
$numlockvalue = (Get-ItemProperty -path 'HKCU:\Control Panel\Keyboard').InitialKeyboardIndicators
if($numlockvalue -eq 2){
return $true
}
else{
return $false
}
}
}
function Get-WinUtilVariables {

Expand Down Expand Up @@ -572,6 +581,37 @@ function Invoke-WinUtilFeatureInstall {
}
}
}
function Invoke-WinUtilNumLock {
<#
.SYNOPSIS
Disables/Enables NumLock on startup
.PARAMETER Enabled
Indicates whether to enable or disable Numlock on startup
#>
Param($Enabled)
Try{
if ($Enabled -eq $false){
Write-Host "Enabling Numlock on startup"
$value = 2
}
else {
Write-Host "Disabling Numlock on startup"
$value = 0
}
$Path = "HKCU:\Control Panel\Keyboard"
Set-ItemProperty -Path $Path -Name InitialKeyboardIndicators -Value $value
}
Catch [System.Security.SecurityException] {
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
}
Catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning $psitem.Exception.ErrorRecord
}
Catch{
Write-Warning "Unable to set $Name due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}
}
function Invoke-WinUtilScript {
<#
Expand Down Expand Up @@ -1074,7 +1114,6 @@ function Invoke-WPFButton {
"WPFtweaksbutton" {Invoke-WPFtweaksbutton}
"WPFAddUltPerf" {Invoke-WPFUltimatePerformance -State "Enabled"}
"WPFRemoveUltPerf" {Invoke-WPFUltimatePerformance -State "Disabled"}
"WPFToggleDarkMode" {Invoke-WPFDarkMode -DarkMoveEnabled $(Get-WinUtilDarkMode)}
"WPFundoall" {Invoke-WPFundoall}
"WPFFeatureInstall" {Invoke-WPFFeatureInstall}
"WPFPanelDISM" {Invoke-WPFPanelDISM}
Expand Down Expand Up @@ -1704,7 +1743,7 @@ function Invoke-WPFToggle {

"WPFToggleDarkMode" {Invoke-WinUtilDarkMode -DarkMoveEnabled $(Get-WinUtilToggleStatus WPFToggleDarkMode)}
"WPFToggleBingSearch" {Invoke-WinUtilBingSearch $(Get-WinUtilToggleStatus WPFToggleBingSearch)}

"WPFToggleNumLock" {Invoke-WinUtilNumLock $(Get-WinUtilToggleStatus WPFToggleNumLock)}
}
}
function Invoke-WPFtweaksbutton {
Expand Down Expand Up @@ -2723,9 +2762,12 @@ $inputXML = '<Window x:Class="WinUtility.MainWindow"
</StackPanel>
<StackPanel Background="{MainBackgroundColor}" SnapsToDevicePixels="True" Grid.Row="1" Grid.Column="1" Margin="10,5">
<Label FontSize="16" Content="Advanced Tweaks - CAUTION"/>
<CheckBox Name="WPFMiscTweaksNum" Content="Enable NumLock on Startup" Margin="5,0" ToolTip="This creates a time vortex and sends you back to the past... or it simply turns numlock on at startup"/>
<CheckBox Name="WPFMiscTweaksLapNum" Content="Disable Numlock on Startup" Margin="5,0" ToolTip="Disables Numlock... Very useful when you are on a laptop WITHOUT 9-key and this fixes that issue when the numlock is enabled!"/>
<CheckBox Name="WPFMiscTweaksExt" Content="Show File Extensions" Margin="5,0"/>
<Label Content="NumLock on Startup" />
<StackPanel Orientation="Horizontal">
<Label Content="Disable" />
<CheckBox Name="WPFToggleNumLock" Style="{StaticResource ToggleSwitchStyle}" Margin="2.5,0"/>
<Label Content="Enable" />
</StackPanel> <CheckBox Name="WPFMiscTweaksExt" Content="Show File Extensions" Margin="5,0"/>
<CheckBox Name="WPFMiscTweaksDisplay" Content="Set Display for Performance" Margin="5,0" ToolTip="Sets the system preferences to performance. You can do this manually with sysdm.cpl as well."/>
<CheckBox Name="WPFMiscTweaksUTC" Content="Set Time to UTC (Dual Boot)" Margin="5,0" ToolTip="Essential for computers that are dual booting. Fixes the time sync with Linux Systems."/>
<CheckBox Name="WPFMiscTweaksDisableUAC" Content="Disable UAC" Margin="5,0" ToolTip="Disables User Account Control. Only recommended for Expert Users."/>
Expand Down Expand Up @@ -3571,8 +3613,7 @@ $sync.configs.preset = '{
"WPFEssTweaksStorage",
"WPFEssTweaksTele",
"WPFEssTweaksWifi",
"WPFMiscTweaksPower",
"WPFMiscTweaksNum"
"WPFMiscTweaksPower"
],
"laptop": [
"WPFEssTweaksAH",
Expand All @@ -3584,8 +3625,7 @@ $sync.configs.preset = '{
"WPFEssTweaksStorage",
"WPFEssTweaksTele",
"WPFEssTweaksWifi",
"WPFMiscTweaksLapPower",
"WPFMiscTweaksLapNum"
"WPFMiscTweaksLapPower"
],
"minimal": [
"WPFEssTweaksHome",
Expand Down Expand Up @@ -5801,28 +5841,6 @@ $sync.configs.tweaks = '{
"
]
},
"WPFMiscTweaksLapNum": {
"Registry": [
{
"Path": "HKU:\\.DEFAULT\\Control Panel\\Keyboard",
"OriginalValue": "1",
"Name": "InitialKeyboardIndicators",
"Value": "0",
"Type": "DWord"
}
]
},
"WPFMiscTweaksNum": {
"Registry": [
{
"Path": "HKU:\\.DEFAULT\\Control Panel\\Keyboard",
"OriginalValue": "1",
"Name": "InitialKeyboardIndicators",
"Value": "80000002",
"Type": "DWord"
}
]
},
"WPFEssTweaksRemoveEdge": {
"InvokeScript": [
"
Expand Down
9 changes: 6 additions & 3 deletions xaml/inputXML.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -501,9 +501,12 @@
</StackPanel>
<StackPanel Background="{MainBackgroundColor}" SnapsToDevicePixels="True" Grid.Row="1" Grid.Column="1" Margin="10,5">
<Label FontSize="16" Content="Advanced Tweaks - CAUTION"/>
<CheckBox Name="WPFMiscTweaksNum" Content="Enable NumLock on Startup" Margin="5,0" ToolTip="This creates a time vortex and sends you back to the past... or it simply turns numlock on at startup"/>
<CheckBox Name="WPFMiscTweaksLapNum" Content="Disable Numlock on Startup" Margin="5,0" ToolTip="Disables Numlock... Very useful when you are on a laptop WITHOUT 9-key and this fixes that issue when the numlock is enabled!"/>
<CheckBox Name="WPFMiscTweaksExt" Content="Show File Extensions" Margin="5,0"/>
<Label Content="NumLock on Startup" />
<StackPanel Orientation="Horizontal">
<Label Content="Disable" />
<CheckBox Name="WPFToggleNumLock" Style="{StaticResource ToggleSwitchStyle}" Margin="2.5,0"/>
<Label Content="Enable" />
</StackPanel> <CheckBox Name="WPFMiscTweaksExt" Content="Show File Extensions" Margin="5,0"/>
<CheckBox Name="WPFMiscTweaksDisplay" Content="Set Display for Performance" Margin="5,0" ToolTip="Sets the system preferences to performance. You can do this manually with sysdm.cpl as well."/>
<CheckBox Name="WPFMiscTweaksUTC" Content="Set Time to UTC (Dual Boot)" Margin="5,0" ToolTip="Essential for computers that are dual booting. Fixes the time sync with Linux Systems."/>
<CheckBox Name="WPFMiscTweaksDisableUAC" Content="Disable UAC" Margin="5,0" ToolTip="Disables User Account Control. Only recommended for Expert Users."/>
Expand Down

0 comments on commit 81fb832

Please sign in to comment.