如何从命令行自动隐藏任务栏

问题描述 投票:0回答:4

有谁知道如何通过命令行或其他方法自动隐藏 Windows 7 中的任务栏?

windows cmd windows-7 taskbar
4个回答
28
投票

从 cmd 提示符或 .cmd 或文件中自动隐藏任务栏。蝙蝠文件:

Windows 7 (StuckRects2)

powershell -command "&{$p='HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2';$v=(Get-ItemProperty -Path $p).Settings;$v[8]=3;&Set-ItemProperty -Path $p -Name Settings -Value $v;&Stop-Process -f -ProcessName explorer}"

Windows 10 (StuckRects3)

powershell -command "&{$p='HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3';$v=(Get-ItemProperty -Path $p).Settings;$v[8]=3;&Set-ItemProperty -Path $p -Name Settings -Value $v;&Stop-Process -f -ProcessName explorer}"

说明

存储该值的注册表项还存储许多其他设置。由于我们只想更改该注册表设置的位置 9(cmd 中的

$v[8]
),因此我们需要保留其他设置。

通常在 cmd 中,使用

reg add
命令来修改注册表就足够了,但我们使用 powershell,因为它可以轻松保留存储在同一注册表项下的其他设置。

Explorer 还需要重新启动才能使更改生效。我们使用

Stop-Process
是因为 Windows 在资源管理器停止时会自动重新启动。

注意:将上述命令中的

$v[8]=3
更改为
$v[8]=2
以撤消此更改(如果您希望任务栏始终可见)。


14
投票

这里有一个小 C 程序,可以切换任务栏窗口的隐藏/显示状态。请注意,当它隐藏时,它实际上完全从屏幕上消失(它不处于自动隐藏模式)。

#include <windows.h>

int main() {
    HWND hwnd = FindWindow("Shell_traywnd", "");
    if (IsWindowVisible(hwnd))
        SetWindowPos(hwnd,0,0,0,0,0,SWP_HIDEWINDOW);
    else
        SetWindowPos(hwnd,0,0,0,0,0,SWP_SHOWWINDOW);
    return 0;
}

使用 SHAppBarMessage。这个切换自动隐藏状态。

#include <windows.h>
#include <shellapi.h>

// This isn't defined for me for some reason.
#ifndef ABM_SETSTATE
#define ABM_SETSTATE 0x0000000A
#endif

int main() {
    APPBARDATA abd = {sizeof abd};
    UINT uState = (UINT) SHAppBarMessage(ABM_GETSTATE, &abd);
    LPARAM param = uState & ABS_ALWAYSONTOP;
    if (uState & ABS_AUTOHIDE)
        abd.lParam = param;
    else
        abd.lParam = ABS_AUTOHIDE | param;
    SHAppBarMessage(ABM_SETSTATE, &abd);
    return 0;
}

0
投票

打开/关闭自动隐藏

PowerShell解决方案:

$location = @{Path = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3'; Name = 'Settings'}
$value = Get-ItemPropertyValue @location
$value[8] = if ($value[8] -Eq 122) {123} Else {122}
Set-ItemProperty @location $value
Stop-Process -Name Explorer

如果使用 Windows 8 或更早版本,请将 Rects3 替换为 Rects2。与 Grenade 的解决方案一样,资源管理器窗口是关闭的。


0
投票

这是不同的,但如果我想完全隐藏它怎么办?因此,即使将鼠标悬停在任务栏上,它仍然不会出现

© www.soinside.com 2019 - 2024. All rights reserved.