How to show/hide taskbar from a desktop shortcut without opening settings menu
6 Answers 6
You need to enable autohide mode in settings. Then use Win + T.
4 Comments
esc doesnt seem to workWin + T till you select the window you want and press enter. Turns out this command is to tab through shortcuts/windows on the taskbar.Actually you will have to do it manually . Right click on task bar then go to taskbar settings then turn on Automatically hide the taskbar in desktop mode then simply you can press ctrl+Esc to see taskbar from any window.
1 Comment
Here's the wrapped PowerShell script that toggles the Taskbar. Just save it to your desktop as toggle_taskbar.cmd and run to toggle it ON/OFF:
@powershell.exe -ExecutionPolicy Bypass -Command "$_=((Get-Content \"%~f0\") -join \"`n\");iex $_.Substring($_.IndexOf(\"goto :\"+\"EOF\")+9)"
@goto :EOF
$signature = @"
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string className, string windowText);
[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr hwnd, int command);
[DllImport("user32.dll")]
public static extern bool IsWindowVisible(IntPtr hwnd);
"@
$taskbar = Add-Type -MemberDefinition $signature -Name Win32ShowWindow -Namespace Win32Functions -PassThru
$hwnd = $taskbar::FindWindow("Shell_TrayWnd", $null)
if ($hwnd -ne [IntPtr]::Zero) {
$isVisible = $taskbar::IsWindowVisible($hwnd)
if ($isVisible) {
# Hide taskbar
$taskbar::ShowWindow($hwnd, 0)
Write-Host "Taskbar hidden"
} else {
# Show taskbar
$taskbar::ShowWindow($hwnd, 1)
Write-Host "Taskbar shown"
}
} else {
Write-Host "Taskbar not found"
}
If you want to replicate the exact Windows auto-hide behavior, use the batch below. The downside is that the Taskbar will pop up when you hover over the lower part of the desktop, and any windows will resize to full screen. I see this as a downside since the space left by the hidden taskbar allows to focus on the largest window more easily.
@powershell.exe -ExecutionPolicy Bypass -Command "$_=((Get-Content \"%~f0\") -join \"`n\");iex $_.Substring($_.IndexOf(\"goto :\"+\"EOF\")+9)"
@goto :EOF
Add-Type -AssemblyName System.Windows.Forms
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class TaskbarAutohide {
[DllImport("shell32.dll")]
public static extern int SHAppBarMessage(uint dwMessage, ref APPBARDATA pData);
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
public static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint Msg, UIntPtr wParam, IntPtr lParam, uint fuFlags, uint uTimeout, out UIntPtr lpdwResult);
[StructLayout(LayoutKind.Sequential)]
public struct APPBARDATA {
public int cbSize;
public IntPtr hWnd;
public uint uCallbackMessage;
public uint uEdge;
public RECT rc;
public IntPtr lParam;
}
[StructLayout(LayoutKind.Sequential)]
public struct RECT {
public int Left;
public int Top;
public int Right;
public int Bottom;
}
public const uint ABM_SETSTATE = 0x0000000A;
public const int ABS_NORMAL = 0x0;
public const int ABS_AUTOHIDE = 0x1;
public const uint WM_SETTINGCHANGE = 0x001A;
public const uint SMTO_ABORTIFHUNG = 0x0002;
}
"@
$regPath = $null
$possiblePaths = @(
"HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3",
"HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2"
)
foreach ($path in $possiblePaths) {
if (Test-Path $path) {
$regPath = $path
break
}
}
if (-not $regPath) {
Write-Host "Could not find taskbar settings in registry. Using API-only method."
$useRegistryMethod = $false
} else {
$useRegistryMethod = $true
}
# Check registry for current auto-hide setting
$isAutoHideEnabled = $false
if ($useRegistryMethod) {
$key = Get-ItemProperty -Path $regPath -ErrorAction SilentlyContinue
if ($key -and $key.Settings) {
$settingsBytes = $key.Settings
# The 9th byte (index 8) contains taskbar settings with bit 0 for auto-hide
$isAutoHideEnabled = ($settingsBytes[8] -band 1) -eq 1
}
}
Write-Host "Current auto-hide setting: $(if ($isAutoHideEnabled) { 'ENABLED' } else { 'DISABLED' })"
$taskbarHwnd = [TaskbarAutohide]::FindWindow("Shell_TrayWnd", $null)
if ($taskbarHwnd -eq [IntPtr]::Zero) {
Write-Host "Taskbar not found!"
exit
}
$abd = New-Object TaskbarAutohide+APPBARDATA
$abd.cbSize = [System.Runtime.InteropServices.Marshal]::SizeOf($abd)
$abd.hWnd = $taskbarHwnd
if ($isAutoHideEnabled) {
# Turn off auto-hide
$abd.lParam = [IntPtr][TaskbarAutohide]::ABS_NORMAL
[void][TaskbarAutohide]::SHAppBarMessage([TaskbarAutohide]::ABM_SETSTATE, [ref]$abd)
if ($useRegistryMethod) {
$settingsBytes = (Get-ItemProperty -Path $regPath).Settings
$settingsBytes[8] = $settingsBytes[8] -band 0xFE # Clear bit 0
[void](Set-ItemProperty -Path $regPath -Name "Settings" -Value $settingsBytes)
}
Write-Host "Taskbar auto-hide DISABLED - taskbar will remain visible"
} else {
# Turn on auto-hide
$abd.lParam = [IntPtr][TaskbarAutohide]::ABS_AUTOHIDE
[void][TaskbarAutohide]::SHAppBarMessage([TaskbarAutohide]::ABM_SETSTATE, [ref]$abd)
if ($useRegistryMethod) {
$settingsBytes = (Get-ItemProperty -Path $regPath).Settings
$settingsBytes[8] = $settingsBytes[8] -bor 1 # Set bit 0
[void](Set-ItemProperty -Path $regPath -Name "Settings" -Value $settingsBytes)
}
Write-Host "Taskbar auto-hide ENABLED - taskbar will hide automatically"
}
$result = [UIntPtr]::Zero
[void][TaskbarAutohide]::SendMessageTimeout([IntPtr]::Zero, [TaskbarAutohide]::WM_SETTINGCHANGE, [UIntPtr]::Zero, [IntPtr]::Zero, [TaskbarAutohide]::SMTO_ABORTIFHUNG, 1000, [ref]$result)
2 Comments
On Windows 11, Enable autohide and press the Windows key like you're going to search for something. This will display the taskbar. You can also press the Win+T if you don't want the search window to open.
Comments
You can do it by using AHK . AutoHotKey. If you hide it, there is going to be a transparent taskbar. so the best thing is setting it to AUTOHIDE.1) install ahk 2) go to desktop , right click , create ahk script 3) open with notepad, delete everything , paste next 4)open script use ALT+BACKSPACE & CTRL+BACKSPACE
;Show taskbar
; ctrl + Backspace Set AUTO HIDE TASKBAR OFF
^Backspace::
HideShowTaskbar2(False)
HideShowTaskbar2(action)
{
static ABM_SETSTATE := 0xA, ABS_AUTOHIDE := 0x1, ABS_ALWAYSONTOP := 0x2
VarSetCapacity(APPBARDATA, size := 2*A_PtrSize + 2*4 + 16 + A_PtrSize, 0)
NumPut(size, APPBARDATA), NumPut(WinExist("ahk_class Shell_TrayWnd"), APPBARDATA, A_PtrSize)
NumPut(action ? ABS_AUTOHIDE : ABS_ALWAYSONTOP, APPBARDATA, size - A_PtrSize)
DllCall("Shell32\SHAppBarMessage", UInt, ABM_SETSTATE, Ptr, &APPBARDATA)
}
Return
;Hide taskbar
; Alt + Backspace Set AUTO HIDE TASKBAR ON
!Backspace::
HideShowTaskbar(True)
HideShowTaskbar(action)
{
static ABM_SETSTATE := 0xA, ABS_AUTOHIDE := 0x1, ABS_ALWAYSONTOP := 0x2
VarSetCapacity(APPBARDATA, size := 2*A_PtrSize + 2*4 + 16 + A_PtrSize, 0)
NumPut(size, APPBARDATA), NumPut(WinExist("ahk_class Shell_TrayWnd"), APPBARDATA, A_PtrSize)
NumPut(action ? ABS_AUTOHIDE : ABS_ALWAYSONTOP, APPBARDATA, size - A_PtrSize)
DllCall("Shell32\SHAppBarMessage", UInt, ABM_SETSTATE, Ptr, &APPBARDATA)
}
return
1 Comment
You need to enable autohide mode in settings.
ToggleTaskbar()
{
Static A_WinID := ""
If Not WinActive("ahk_class Shell_TrayWnd")
{
A_WinID := WinExist("A")
WinShow, ahk_class Shell_TrayWnd
WinActivate, ahk_class Shell_TrayWnd
}
Else
{
If A_WinID
{
WinActivate, ahk_id %A_WinID%
A_WinID := ""
}
}
}
shell::value for changing taskbar show/hide. It's not clear why people expect every single feature to have a "can be triggered from a batch file".