3

How to show/hide taskbar from a desktop shortcut without opening settings menu

asked Oct 12, 2021 at 17:01
5
  • 2
    Does this answer your question? A command or message or DLL call to set automatic hiding of Windows taskbar? Commented Oct 12, 2021 at 17:32
  • I thing so. but how can i implement this without using a third party application. can i create using vbs or other code. Commented Oct 13, 2021 at 4:11
  • The linked question shows how to do it in AutoHotKey. The underlying algorithm should be apparent, and you can translate it to whatever other language you like, assuming it can call Win32 APIs. Commented Oct 13, 2021 at 12:45
  • this shortcut location opens task view:- explorer shell:::{3080F90E-D7AD-11D9-BD98-0000947B0257} .Is there way to do so? Commented Oct 13, 2021 at 16:24
  • 1
    There is no 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". Commented Oct 13, 2021 at 18:44

6 Answers 6

6

You need to enable autohide mode in settings. Then use Win + T.

answered May 13, 2023 at 8:10
Sign up to request clarification or add additional context in comments.

4 Comments

I think (or presume) that the OP wants to do this programmatically.
@AdrianMole Thought he meant a keyboard shortcut from the desktop.
This works! but how would you hide it again? hitting esc doesnt seem to work
@Gabriel Press Win + T till you select the window you want and press enter. Turns out this command is to tab through shortcuts/windows on the taskbar.
1

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.

answered Oct 12, 2021 at 17:08

1 Comment

I thing so. but how can i implement this without using a third party application. can i create using vbs or other code.
1

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

You can also place the .cmd elsewhere and put only its shortcut on the desktop to change its icon or set running to Minimized if you want it to look nicer. (I tested this approach only on Windows 10.)
Thanks man. This is exactly what I needed.
0

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.

answered Dec 10, 2024 at 13:58

Comments

-1

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
answered Jan 3, 2023 at 0:35

1 Comment

I tried the above AutoHotkey script in Windows 11 and it did not work. Ctrl+Backspace did nothing and Alt+Backspace shrank the size of the Taskbar but did not hide it. Open full screen windows did not automatically resize as happens when the Taskbar is actually hidden.
-1

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 := ""
 }
 }
}
answered Apr 26, 2023 at 7:40

1 Comment

I tried the above in AutoHotkey and all it did was activate and deactivate the current windows.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.