Windows 10 1903 and Later 搜索中心居中脚本

网上冲浪时看到的一个有意思的 powershell 脚本。
在这里记录一下

首先更改策略允许执行powershell脚本

set-ExecutionPolicy RemoteSigned

然后执行如下脚本:

$BASE_PATH = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Search'
$RADIUS_PATH = "$BASE_PATH\Flighting\Override"

function CustimizedNewItemProperty($Path, $Name, $Value) {
    $null = New-ItemProperty -Path $Path -Name $Name -PropertyType DWord -Value $Value
}

function ToCenter($Radius) {
    $null = ToDefault
    $null = New-Item -ItemType String -Path $RADIUS_PATH
    CustimizedNewItemProperty $BASE_PATH ImmersiveSearch 1
    CustimizedNewItemProperty $RADIUS_PATH ImmersiveSearchFull 1
    CustimizedNewItemProperty $RADIUS_PATH CenterScreenRoundedCornerRadius $Radius
    '设置成功'
}

function ToDefault {
    if (Test-Path -Path $RADIUS_PATH) {
        $null = Remove-Item -Path $RADIUS_PATH -Recurse -Force
    }
    if ($null -ne (Get-ItemProperty -Path $BASE_PATH | Select-String -Pattern "ImmersiveSearch")) {
        $null = Remove-ItemProperty -Path $BASE_PATH -Name ImmersiveSearch -Force
    }
    '恢复完成'
}

function Menu {
    Clear-Host
    @"
----------------------------
  Windows 10 1903 and Later
       Search 居中脚本
            V0.01 2019.10.02
                @AUTHOR LOGI
----------------------------
0. 退出
1. 居中
2. 恢复
----------------------------
"@
    switch (Read-Host '请选择') {
        0 { Exit 0 }
        1 { 
            try {
                ToCenter ([int](Read-Host '请输入圆角大小(0-10)'))
            }
            catch {
                ToCenter 0
            }
        }
        2 { ToDefault }
        Default { Menu }
    }
}

while ($true) {
    Menu
    '----------------------------'
    '请按任意键继续...'
    [void][System.Console]::ReadKey($true)
}

原文链接: https://logi.ml/script/center-win10-search-ui.html

本文链接: https://blog.frostmiku.com/archives/11/
1 + 6 =
快来做第一个评论的人吧~