Hide/show taskbar in Windows 10

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
farse
Posts: 3
Joined: 16 May 2022, 08:49

Re: Hide/show taskbar in Windows 10

Post by farse » 16 May 2022, 09:02

teadrinker wrote:
10 Aug 2021, 12:58
Assuming the taskbar is at the bottom of the screen, this should work:

Code: Select all

$F12:: HideShowTaskbar()

HideShowTaskbar() {
   static SW_HIDE := 0, SW_SHOWNA := 8, SPI_SETWORKAREA := 0x2F
   DetectHiddenWindows, On
   hTB := WinExist("ahk_class Shell_TrayWnd")
   WinGetPos,,,, H
   hBT := WinExist("ahk_class Button ahk_exe Explorer.EXE")  ; for Windows 7
   b := DllCall("IsWindowVisible", "Ptr", hTB)
   for k, v in [hTB, hBT]
      ( v && DllCall("ShowWindow", "Ptr", v, "Int", b ? SW_HIDE : SW_SHOWNA) )
   VarSetCapacity(RECT, 16, 0)
   NumPut(A_ScreenWidth, RECT, 8)
   NumPut(A_ScreenHeight - !b*H, RECT, 12, "UInt")
   DllCall("SystemParametersInfo", "UInt", SPI_SETWORKAREA, "UInt", 0, "Ptr", &RECT, "UInt", 0)
   WinGet, List, List
   Loop % List {
      WinGet, res, MinMax, % "ahk_id" . List%A_Index%
      if (res = 1)
         WinMove, % "ahk_id" . List%A_Index%,, 0, 0, A_ScreenWidth, A_ScreenHeight - !b*H
   }
}
This works very well, but how can I disable taskbar on second window as well? It works only half way, both taskbars disappear but only SecondayyTrayWnd appear back, TrayWnd appears and disappears instantly

Code: Select all

$F12:: HideBoth(hide := !hide)

HideBoth(action) {
    HideShowTaskbar("Shell_TrayWnd", action)
    HideShowTaskbar("Shell_SecondaryTrayWnd", action)
}
HideShowTaskbar(TaskShell,action) {
   static SW_HIDE := 0, SW_SHOWNA := 8, SPI_SETWORKAREA := 0x2F
   DetectHiddenWindows, On
   hTB := WinExist("ahk_class " . TaskShell)
   WinGetPos,,,, H
   b := DllCall("IsWindowVisible", "Ptr", hTB)
   DllCall("ShowWindow", "Ptr", hTB, "Int", action ? SW_HIDE : SW_SHOWNA)
   VarSetCapacity(RECT, 16, 0)
   NumPut(A_ScreenWidth, RECT, 8)
   NumPut(A_ScreenHeight - !b*H, RECT, 12, "UInt")
   DllCall("SystemParametersInfo", "UInt", SPI_SETWORKAREA, "UInt", 0, "Ptr", &RECT, "UInt", 0)
   WinGet, List, List
   Loop % List {
      WinGet, res, MinMax, % "ahk_id" . List%A_Index%
      if (res = 1)
         WinMove, % "ahk_id" . List%A_Index%,, 0, 0, A_ScreenWidth, A_ScreenHeight - !b*H
   }
}
What am I doing wrong?

I have this code that works well on both screens, but I am trying other variants aswell

Code: Select all

hide := true
; HideShowTaskbar(true)
^!U:: HideShowTaskbar(hide := !hide)

HideShowTaskbar(action) {
    ; MsgBox, done
    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)
    if(action = true)
    {

        WinSet, Transparent, 0, ahk_class Shell_TrayWnd
        WinSet, Transparent, 0, ahk_class Shell_SecondaryTrayWnd
    }
    else {

        WinSet, Transparent, 255, ahk_class Shell_TrayWnd
        WinSet, TransColor, OFF, ahk_class Shell_TrayWnd
        WinSet, Transparent, OFF, ahk_class Shell_TrayWnd
        WinSet, Redraw,, ahk_class Shell_TrayWnd

        WinSet, Transparent, 255, ahk_class Shell_SecondaryTrayWnd
        WinSet, TransColor, OFF, ahk_class Shell_SecondaryTrayWnd
        WinSet, Transparent, OFF, ahk_class Shell_SecondaryTrayWnd
        WinSet, Redraw,, ahk_class Shell_SecondaryTrayWnd
    }
}

teadrinker
Posts: 4347
Joined: 29 Mar 2015, 09:41
Contact:

Re: Hide/show taskbar in Windows 10

Post by teadrinker » 16 May 2022, 10:32

farse wrote: how can I disable taskbar on second window as well?
Sorry, I currently have no second monitor to test the code.

jhotayex
Posts: 1
Joined: 12 Aug 2022, 10:32

Re: Hide/show taskbar in Windows 10

Post by jhotayex » 12 Aug 2022, 10:36

teadrinker wrote:
09 Jan 2019, 18:26
Try this:

Code: Select all

$F12:: HideShowTaskbar(hide := !hide)
   
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)
}

This code perfectly works in windows 11 latest build 12/08/2022 . Thanks for this code :thumbup: :thumbup:

luiss1980
Posts: 5
Joined: 22 Nov 2022, 21:23

Re: Hide/show taskbar in Windows 10

Post by luiss1980 » 23 Nov 2022, 02:54

Wanted to share another approach! Got this working just tonight :arrow: (credit @boiler)

Code: Select all

f12::
RegRead, TaskbarToggle, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3, Settings
	If (TaskbarToggle = "30000000feffffff02800000030000003e0000001e000000000000001a04000080070000380400006000000001000000")
		RegWrite, REG_BINARY, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3, Settings, 30000000feffffff03800000030000003e0000001e000000000000001a04000080070000380400006000000001000000
	else ; If (TaskbarToggle = 30000000feffffff03800000030000003e0000001e000000000000001a04000080070000380400006000000001000000)
		RegWrite, REG_BINARY, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3, Settings, 30000000feffffff02800000030000003e0000001e000000000000001a04000080070000380400006000000001000000
process, close, explorer.exe
Return

Windows 10 Home, 22H2, build 19045.2130

farse
Posts: 3
Joined: 16 May 2022, 08:49

Re: Hide/show taskbar in Windows 10

Post by farse » 23 Nov 2022, 04:01

luiss1980 wrote:
23 Nov 2022, 02:54
Wanted to share another approach! Got this working just tonight :arrow: (credit @boiler)

Code: Select all

f12::
RegRead, TaskbarToggle, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3, Settings
	If (TaskbarToggle = "30000000feffffff02800000030000003e0000001e000000000000001a04000080070000380400006000000001000000")
		RegWrite, REG_BINARY, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3, Settings, 30000000feffffff03800000030000003e0000001e000000000000001a04000080070000380400006000000001000000
	else ; If (TaskbarToggle = 30000000feffffff03800000030000003e0000001e000000000000001a04000080070000380400006000000001000000)
		RegWrite, REG_BINARY, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3, Settings, 30000000feffffff02800000030000003e0000001e000000000000001a04000080070000380400006000000001000000
process, close, explorer.exe
Return

Windows 10 Home, 22H2, build 19045.2130
You could use Tabame to hide the taskbar, I've made it:

https://github.com/Far-Se/tabame

themegabyte
Posts: 1
Joined: 06 Jan 2023, 10:30

Re: Hide/show taskbar in Windows 10

Post by themegabyte » 06 Jan 2023, 10:34

teadrinker wrote:
09 Jan 2019, 18:26
Try this:

Code: Select all

$F12:: HideShowTaskbar(hide := !hide)
   
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)
}
Hey man, can you explain slightly (whatever your kind time allows) that how this is working? I am just fascinated how this works so cleanly. I could expand this for other options for sure!

I currently use this: https://superuser.com/questions/654170/how-to-toggle-the-auto-hide-status-of-the-windows-taskbar/656145#656145

But that user is inactive since 2014, figured I will ask you : )

Thank you!

teadrinker
Posts: 4347
Joined: 29 Mar 2015, 09:41
Contact:

Re: Hide/show taskbar in Windows 10

Post by teadrinker » 06 Jan 2023, 11:35

themegabyte wrote: how this is working?
Hi @themegabyte
The only api that my script uses is SHAppBarMessage. You can read the full description here. I can't explain in more detail! ;)

starionx
Posts: 17
Joined: 23 Jul 2015, 22:29

Re: Hide/show taskbar in Windows 10

Post by starionx » 06 Jan 2023, 20:02

This seems a little simpler (I found it some time ago)

Code: Select all

+ScrollLock::	;toggle Task Bar on/off
if toggle := !toggle
   WinHide ahk_class Shell_TrayWnd
else
   WinShow ahk_class Shell_TrayWnd
return
edit -

I just found this post which I believe should work for 2 monitors

teadrinker
Posts: 4347
Joined: 29 Mar 2015, 09:41
Contact:

Re: Hide/show taskbar in Windows 10

Post by teadrinker » 06 Jan 2023, 22:57

@starionx
Try hiding the taskbar and maximizing some window, you'll see what's wrong with this approach.

starionx
Posts: 17
Joined: 23 Jul 2015, 22:29

Re: Hide/show taskbar in Windows 10

Post by starionx » 07 Jan 2023, 01:22

I guess that's a matter of perspective. For me, it's a way of getting the taskbar up on fullscreen windowed games.
;)

clr
Posts: 6
Joined: 15 Apr 2017, 11:11

Re: Hide/show taskbar in Windows 10

Post by clr » 15 Mar 2023, 10:47

teadrinker wrote:
09 Jan 2019, 18:26
Try this:

Code: Select all

$F12:: HideShowTaskbar(hide := !hide)
   
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)
}
@teadrinker , thank you very much for this snippet. It works beautifully.

MedBooster
Posts: 54
Joined: 24 Nov 2022, 12:33

Re: Hide/show taskbar in Windows 10

Post by MedBooster » 03 Dec 2023, 09:40

Would there be a way to modify this to even keep the taskbar on top when in full screen mode in different programs?

MedBooster
Posts: 54
Joined: 24 Nov 2022, 12:33

Re: Hide/show taskbar in Windows 10

Post by MedBooster » 03 Dec 2023, 09:59

I've been trying to use struckrects3 in the registry. You can see it described in the website I linked to.

'
;move taskbar to top ;this does not work yet
;reference https://www.tomshardware.com/how-to/windows-11-taskbar-move-to-top

^+#Space::

; Set the registry key path
RegPath := "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3"

; Read the Settings binary value from the registry
RegRead, SettingsValue, % RegPath, Settings

; Check the current value, if it's "03", change it to "01", otherwise change it to "03"
NewSettingsValue := (SubStr(SettingsValue, 17, 2) = "03") ? (SubStr(SettingsValue, 1, 34) . "01" . SubStr(SettingsValue, 37)) : (SubStr(SettingsValue, 1, 34) . "03" . SubStr(SettingsValue, 37))

; Write the updated binary value back to the registry
RegWrite, REG_BINARY, % RegPath, Settings, % NewSettingsValue

; Restart Windows Explorer
Run, %comspec% /c taskkill /f /im explorer.exe & start explorer.exe


Return

Post Reply

Return to “Ask for Help (v1)”