Skip to content

Commit

Permalink
Merge pull request #400 from HolisticDeveloper/Set-TaskbarOptions-mul…
Browse files Browse the repository at this point in the history
…ti-monitor

(GH-399) Multi-monitor support in Set-TaskbarOptions
  • Loading branch information
pauby authored Feb 26, 2020
2 parents 34fe98e + 6a9d13f commit 03f6029
Show file tree
Hide file tree
Showing 6 changed files with 338 additions and 213 deletions.
2 changes: 1 addition & 1 deletion Boxstarter.WinConfig/Boxstarter.WinConfig.psm1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Resolve-Path $PSScriptRoot\*.ps1 |
% { . $_.ProviderPath }

Export-ModuleMember Disable-UAC, Enable-UAC, Get-UAC, Disable-InternetExplorerESC, Disable-GameBarTips, Get-ExplorerOptions, Set-TaskbarSmall, Install-WindowsUpdate, Move-LibraryDirectory, Enable-RemoteDesktop, Set-ExplorerOptions, Get-LibraryNames, Update-ExecutionPolicy, Enable-MicrosoftUpdate, Disable-MicrosoftUpdate, Set-StartScreenOptions, Set-CornerNavigationOptions, Set-WindowsExplorerOptions, Set-TaskbarOptions, Disable-BingSearch, Set-BoxstarterPageFile
Export-ModuleMember Disable-UAC, Enable-UAC, Get-UAC, Disable-InternetExplorerESC, Disable-GameBarTips, Get-ExplorerOptions, Set-TaskbarSmall, Install-WindowsUpdate, Move-LibraryDirectory, Enable-RemoteDesktop, Set-ExplorerOptions, Get-LibraryNames, Update-ExecutionPolicy, Enable-MicrosoftUpdate, Disable-MicrosoftUpdate, Set-StartScreenOptions, Set-CornerNavigationOptions, Set-WindowsExplorerOptions, Set-BoxstarterTaskbarOptions, Disable-BingSearch, Set-BoxstarterPageFile
2 changes: 1 addition & 1 deletion Boxstarter.WinConfig/Boxstarter.WinConfig.pssproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<Content Include="Disable-MicrosoftUpdate.ps1" />
<Content Include="Enable-MicrosoftUpdate.ps1" />
<Content Include="Set-StartScreenOptions.ps1" />
<Content Include="Set-TaskbarOptions.ps1" />
<Content Include="Set-BoxstarterTaskbarOptions.ps1" />
<Content Include="Set-WindowsExplorerOptions.ps1" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Expand Down
242 changes: 242 additions & 0 deletions Boxstarter.WinConfig/Set-BoxstarterTaskbarOptions.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
function Set-BoxstarterTaskbarOptions {
<#
.SYNOPSIS
Sets options for the Windows Task Bar.
.PARAMETER Lock
Locks the taskbar.
.PARAMETER UnLock
Unlocks the taskbar.
.PARAMETER AutoHide
Autohides the taskbar.
.PARAMETER NoAutoHide
No autohiding on the taskbar.
.PARAMETER Size
Changes the size of the taskbar icons. Valid inputs are Small and Large.
.PARAMETER Dock
Changes the location in which the taskbar is docked. Valid inputs are Top, Left, Bottom and Right.
.PARAMETER Combine
Changes the taskbar icon combination style. Valid inputs are Always, Full, and Never.
.PARAMETER AlwaysShowIconsOn
Turn on always show all icons in the notification area.
.PARAMETER AlwaysShowIconsOff
Turn off always show all icons in the notification area.
.PARAMETER MultiMonitorOn
Turn on Show tasbkar on all displays.
.PARAMETER MultiMonitorOff
Turn off Show taskbar on all displays.
.PARAMETER MultiMonitorMode
Changes the behavior of the taskbar when using multiple displays. Valid inputs are All, MainAndOpen, and Open.
.PARAMETER MultiMonitorCombine
Changes the taskbar icon combination style for non-primary displays. Valid inputs are Always, Full, and Never.
.EXAMPLE
Set-BoxstarterTaskbarOptions -Lock -AutoHide -AlwaysShowIconsOff -MultiMonitorOff
Locks the taskbar, enabled auto-hiding of the taskbar, turns off showing icons
in the notification area and turns off showing the taskbar on multiple monitors.
.EXAMPLE
Set-BoxstarterTaskbarOptions -Unlock -AlwaysShowIconsOn -Size Large -MultiMonitorOn -MultiMonitorCombine Always
Unlocks the taskbar and always shows large notification icons. Sets
multi-monitor support and always combine icons on non-primary monitors.
#>
[CmdletBinding(DefaultParameterSetName='unlock')]
param(
[Parameter(ParameterSetName='lockhide')]
[Parameter(ParameterSetName='locknohide')]
[switch]
$Lock,

[Parameter(ParameterSetName='unlock')]
[Parameter(ParameterSetName='unlockhide')]
[Parameter(ParameterSetName='unlocknohide')]
[switch]
$UnLock,

[Parameter(ParameterSetName='lockhide')]
[Parameter(ParameterSetName='unlockhide')]
[switch]
$AutoHide,

[Parameter(ParameterSetName='locknohide')]
[Parameter(ParameterSetName='unlocknohide')]
[switch]
$NoAutoHide,

[Parameter(ParameterSetName='AlwaysShowIconsOn')]
[switch]
$AlwaysShowIconsOn,

[Parameter(ParameterSetName='AlwaysShowIconsOff')]
[switch]
$AlwaysShowIconsOff,

[ValidateSet('Small','Large')]
[String]
$Size,

[ValidateSet('Top','Left','Bottom','Right')]
[String]
$Dock,

[ValidateSet('Always','Full','Never')]
[String]
$Combine,

[Parameter(ParameterSetName='MultiMonitorOff')]
[switch]
$MultiMonitorOff,

[Parameter(ParameterSetName='MultiMonitorOn')]
[switch]
$MultiMonitorOn,

[Parameter(ParameterSetName='MultiMonitorOn')]
[ValidateSet('All', 'MainAndOpen', 'Open')]
[String]
$MultiMonitorMode,

[Parameter(ParameterSetName='MultiMonitorOn')]
[ValidateSet('Always','Full','Never')]
[String]
$MultiMonitorCombine
)

$explorerKey = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer'
$key = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced'
$settingKey = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2'

if (-not (Test-Path -Path $settingKey)) {
$settingKey = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3'
}

if (Test-Path -Path $key) {
if ($Lock) {
Set-ItemProperty -Path $key -Name TaskbarSizeMove -Value 0
}

if ($UnLock) {
Set-ItemProperty -Path $key -Name TaskbarSizeMove -Value 1
}

switch ($Size) {
"Small" {
Set-ItemProperty -Path $key -Name TaskbarSmallIcons -Value 1
}

"Large" {
Set-ItemProperty -Path $key -Name TaskbarSmallIcons -Value 0
}
}

switch ($Combine) {
"Always" {
Set-ItemProperty -Path $key -Name TaskbarGlomLevel -Value 0
}

"Full" {
Set-ItemProperty -Path $key -Name TaskbarGlomLevel -Value 1
}

"Never" {
Set-ItemProperty -Path $key -Name TaskbarGlomLevel -Value 2
}
}

if ($MultiMonitorOn) {
Set-ItemProperty -Path $key -Name MMTaskbarEnabled -Value 1

switch ($MultiMonitorMode) {
"All" {
Set-ItemProperty -Path $key -Name MMTaskbarMode -Value 0
}

"MainAndOpen" {
Set-ItemProperty -Path $key -Name MMTaskbarMode -Value 1
}

"Open" {
Set-ItemProperty -Path $key -Name MMTaskbarMode -Value 2
}
}

switch ($MultiMonitorCombine) {
"Always" {
Set-ItemProperty -Path $key -Name MMTaskbarGlomLevel -Value 0
}

"Full" {
Set-ItemProperty -Path $key -Name MMTaskbarGlomLevel -Value 1
}

"Never" {
Set-ItemProperty -Path $key -Name MMTaskbarGlomLevel -Value 2
}
}
}

if ($MultiMonitorOff) {
Set-ItemProperty -Path $key -Name MMTaskbarEnabled -Value 0
}
}

if (Test-Path -Path $settingKey) {
$settings = (Get-ItemProperty -Path $settingKey -Name Settings).Settings

switch ($Dock) {
"Top" {
$settings[12] = 0x01
}

"Left" {
$settings[12] = 0x00
}

"Bottom" {
$settings[12] = 0x03
}

"Right" {
$settings[12] = 0x02
}
}

if ($AutoHide) {
$settings[8] = $settings[8] -bor 1
}

if ($NoAutoHide) {
$settings[8] = $settings[8] -band 0
Set-ItemProperty -Path $settingKey -Name Settings -Value $settings
}

Set-ItemProperty -Path $settingKey -Name Settings -Value $settings
}

if (Test-Path -Path $explorerKey) {
if ($AlwaysShowIconsOn) {
Set-ItemProperty -Path $explorerKey -Name 'EnableAutoTray' -Value 0
}

if ($alwaysShowIconsOff) {
Set-ItemProperty -Path $explorerKey -Name 'EnableAutoTray' -Value 1
}
}

Restart-Explorer
}

New-Alias -Name Set-TaskbarOptions -Value Set-BoxstarterTaskbarOptions
117 changes: 0 additions & 117 deletions Boxstarter.WinConfig/Set-TaskbarOptions.ps1

This file was deleted.

6 changes: 3 additions & 3 deletions Boxstarter.WinConfig/Set-TaskbarSmall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ function Set-TaskbarSmall {
.SYNOPSIS
Makes the windows task bar skinny
#>
Write-Warning "This command is deprecated, use Set-TaskbarOptions instead."
Write-Warning "Your call to this function will now be routed to the Set-TaskbarOptions function."
Write-Warning "This command is deprecated, use Set-BoxstarterTaskbarOptions instead."
Write-Warning "Your call to this function will now be routed to the Set-BoxstarterTaskbarOptions function."

Set-TaskbarOptions -Size Small
Set-BoxstarterTaskbarOptions -Size Small
}
Loading

0 comments on commit 03f6029

Please sign in to comment.