Hide/show taskbar in Windows 10

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
AmDeG 11
Posts: 388
Joined: 28 Nov 2013, 11:42

Hide/show taskbar in Windows 10

Post by AmDeG 11 » 09 Jan 2019, 16:19

at this script I was able to hide/show the taskbar in Windows 10
it works but not always

anyone has something better?

Code: Select all

RAlt & LWin:: ;hide/unhide taskbar (toogle) 
    Run control.exe /name Microsoft.Taskbar
    WinWait ahk_class ApplicationFrameWindow
    WinRestore ahk_class ApplicationFrameWindow
    WinMaximize ahk_class ApplicationFrameWindow
    Sleep, 800
    Send {Back}{Tab 3}             
    Sleep 1000
    Send {Space}
    Sleep 800
    Send !{F4}
return

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

Re: Hide/show taskbar in Windows 10

Post by teadrinker » 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)
}

AmDeG 11
Posts: 388
Joined: 28 Nov 2013, 11:42

Re: Hide/show taskbar in Windows 10

Post by AmDeG 11 » 09 Jan 2019, 18:54

superb!

however I cannot take advantage of the lower part when the task bar is hidden

In the past, in order to command a window to become half screen I had to determine the specific area (if not was not always doing directly that):

Code: Select all

#z::   ;; right half screen
                 WinGet, active_id, ID, A
                 WinGet, MinMaxState, MinMax, ahk_id %active_id% 
                   if (MinMaxState = 1)	
                 WinRestore, ahk_id %active_id%
                 WinMove ahk_id %active_id%,,1920,0,1920,2100
                  WinActivate
                  Return 
is there a way to include that when the taskbar is hidden the Height of this window reaches to 2171 ?

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

Re: Hide/show taskbar in Windows 10

Post by teadrinker » 10 Jan 2019, 11:54

I'm not sure, what is the problem:

Code: Select all

#z::
   WinWait, A
   WinGet, MinMax, MinMax
   if MinMax
      WinRestore
   WinGetPos,, Y,,, ahk_class Shell_TrayWnd
   WinMove,,, A_ScreenWidth//2, 0, A_ScreenWidth//2, Y
   Return
?

AmDeG 11
Posts: 388
Joined: 28 Nov 2013, 11:42

Re: Hide/show taskbar in Windows 10

Post by AmDeG 11 » 10 Jan 2019, 15:36

good
it works ok though it does not get to very right border and bottom

what would it be the difference a the WinMove line to a similar script for the left half side?

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

Re: Hide/show taskbar in Windows 10

Post by teadrinker » 10 Jan 2019, 21:23

Code: Select all

#z::
#x::
   hWnd := WinExist("A")
   WinGet, MinMax, MinMax
   if MinMax
      WinRestore
   WinGetPos,, Y_TaskBar,,, ahk_class Shell_TrayWnd
   dX := dW := dH := 0
   VarSetCapacity(RECT, 16, 0)
   if DllCall("Dwmapi\DwmGetWindowAttribute", Ptr, hWnd, UInt, DWMWA_EXTENDED_FRAME_BOUNDS := 9, Ptr, &RECT, UInt, 16) = 0  {
      WinGetPos, X, Y, W, H
      dX := NumGet(RECT, "Int") - X
      dW := X + W - NumGet(RECT, 8, "Int") + dX
      dH := Y + H - NumGet(RECT, 12, "Int")
   }
   WinMove,,, (A_ThisHotkey =  "#z" ? 0 : A_ScreenWidth//2) - dX, 0, A_ScreenWidth//2 + dW, Y_TaskBar + dH
   Return
Win + Z left side, Win + X right side.

AmDeG 11
Posts: 388
Joined: 28 Nov 2013, 11:42

Re: Hide/show taskbar in Windows 10

Post by AmDeG 11 » 11 Jan 2019, 10:39

all solved - you understood perfectly well my concern
absolutely great
thanks so much !

User avatar
JoeWinograd
Posts: 2198
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Hide/show taskbar in Windows 10

Post by JoeWinograd » 16 Feb 2021, 14:07

teadrinker wrote:Try this
W10 Pro 64-bit v20H2
AHK 1.1.33.02 U64

Hi teadrinker,
I'm using this code from your earlier post:

Code: Select all

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)
}
A call to HideShowTaskbar("ABS_AUTOHIDE") works perfectly, auto-hiding the taskbar. However, a subsequent call to HideShowTaskbar("ABS_ALWAYSONTOP") does not work, i.e., the taskbar remains in auto-hide state. Does it work for you? Thanks, Joe

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

Re: Hide/show taskbar in Windows 10

Post by teadrinker » 16 Feb 2021, 14:53

Hi Joe
Use HideShowTaskbar(true) to hide the taskbar, HideShowTaskbar(false) to show.

User avatar
JoeWinograd
Posts: 2198
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Hide/show taskbar in Windows 10

Post by JoeWinograd » 16 Feb 2021, 15:39

Hi teadrinker,
I obviously misunderstood the parameter to the function...my bad. The calls with True and False work perfectly! Thanks much! Stay safe, Joe

User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Re: Hide/show taskbar in Windows 10

Post by milkygirl90 » 08 Aug 2021, 19:48

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)
}
Hi! Came across your awesome script and just wanted to say thank you. Would like to ask, is it possible to eliminate the "slide away" animation and make it immediately appear/hide instead?

In addition, how do I disable taskbar from showing when hovering over taskbar area? I just want to show/hide using hotkeys instea.

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

Re: Hide/show taskbar in Windows 10

Post by teadrinker » 08 Aug 2021, 20:00

Hi,
I'll take a look at it tomorrow.

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

Re: Hide/show taskbar in Windows 10

Post by teadrinker » 09 Aug 2021, 08:50

milkygirl90 wrote: is it possible to eliminate the "slide away" animation and make it immediately appear/hide instead?

In addition, how do I disable taskbar from showing when hovering over taskbar area? I just want to show/hide using hotkeys instea.
No, unfortunately, I've not found such capabilities in this api.

malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: Hide/show taskbar in Windows 10

Post by malcev » 09 Aug 2021, 17:02

Code: Select all

WinHide, ahk_class Shell_TrayWnd

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

Re: Hide/show taskbar in Windows 10

Post by teadrinker » 10 Aug 2021, 01:59

If I were OP, I'd ask you to write the complete code. :)

malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: Hide/show taskbar in Windows 10

Post by malcev » 10 Aug 2021, 07:18

:))

Code: Select all

$F12:: HideShowTaskbar(hide := !hide)
   
HideShowTaskbar(action)
{
   if action
      WinHide, ahk_class Shell_TrayWnd
   else
      WinShow, ahk_class Shell_TrayWnd
}

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

Re: Hide/show taskbar in Windows 10

Post by teadrinker » 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
   }
}

malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: Hide/show taskbar in Windows 10

Post by malcev » 10 Aug 2021, 13:44

If user has custom toolbars - then better to use SPI_GETWORKAREA before SPI_SETWORKAREA.

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

Re: Hide/show taskbar in Windows 10

Post by teadrinker » 10 Aug 2021, 13:50

I've thought about it, but what if the script starts when the workarea has already been changed?

shuq
Posts: 1
Joined: 31 Aug 2021, 08:24

Re: Hide/show taskbar in Windows 10

Post by shuq » 31 Aug 2021, 08:37

@
AmDeG 11 wrote: at this script I was able to hide/show the taskbar in Windows 10
it works but not always

anyone has something better?

Code: Select all

RAlt & LWin:: ;hide/unhide taskbar (toogle) 
    Run control.exe /name Microsoft.Taskbar
    WinWait ahk_class ApplicationFrameWindow
    WinRestore ahk_class ApplicationFrameWindow
    WinMaximize ahk_class ApplicationFrameWindow
    Sleep, 800
    Send {Back}{Tab 3}             
    Sleep 1000
    Send {Space}
    Sleep 800
    Send !{F4}
return
Thanks, the code helps a lot

Post Reply

Return to “Ask for Help (v1)”