Is there a way to hide the Windows taskbar using Python? If not- is there a way to disable or to re-size and lock it using the registry?
Asked
Active
Viewed 3,128 times
2 Answers
8
Microsoft support document KB186119 demonstrates how to hide the taskbar using Visual Basic. Here's a ctypes version for Python, but using ShowWindow
instead of SetWindowPos
:
import ctypes
from ctypes import wintypes
user32 = ctypes.WinDLL("user32")
SW_HIDE = 0
SW_SHOW = 5
user32.FindWindowW.restype = wintypes.HWND
user32.FindWindowW.argtypes = (
wintypes.LPCWSTR, # lpClassName
wintypes.LPCWSTR) # lpWindowName
user32.ShowWindow.argtypes = (
wintypes.HWND, # hWnd
ctypes.c_int) # nCmdShow
def hide_taskbar():
hWnd = user32.FindWindowW(u"Shell_traywnd", None)
user32.ShowWindow(hWnd, SW_HIDE)
def unhide_taskbar():
hWnd = user32.FindWindowW(u"Shell_traywnd", None)
user32.ShowWindow(hWnd, SW_SHOW)

Eryk Sun
- 33,190
- 5
- 92
- 111
-
2The most beautiful thing about this code is that it continues to work up to Windows 10. – IronManMark20 Aug 01 '15 at 00:17
-
Is there a possibility to also hide the start button? Right now it still stays. – Henrik Sep 24 '15 at 15:45
-
@Henrik, for older versions of Windows, try finding the start button or orb using FindWindowEx, as I did in [this answer](http://stackoverflow.com/a/16651313/205580). To clarify, in Windows 10 hiding the taskbar also hides the start button. – Eryk Sun Sep 24 '15 at 17:18
-
Thanks a lot. really appreciate it. works prefectly on windows 10 – Hossein Jun 22 '20 at 02:04
1
Just to add to @eryksun answer, if you try this in windows 7 you would still get to see the start button... I did i little tweek in his code to
1) Hide the start button (with the hWnd_btn_start = user32.FindWindowW(u"Button", 'Start')
)
2) Now you can pass Hide (default behaviour) or Show to the command line to show or hide the taskbar.
import ctypes
import sys
from ctypes import wintypes
user32 = ctypes.WinDLL("user32")
SW_HIDE = 0
SW_SHOW = 5
HIDE = True;
for idx,item in enumerate(sys.argv):
print(idx, item);
if (idx == 1 and item.upper() == 'SHOW'):
HIDE = False;
#HIDE = sys.argv[1] = 'HIDE' ? True : False;
user32.FindWindowW.restype = wintypes.HWND
user32.FindWindowW.argtypes = (
wintypes.LPCWSTR, # lpClassName
wintypes.LPCWSTR) # lpWindowName
user32.ShowWindow.argtypes = (
wintypes.HWND, # hWnd
ctypes.c_int) # nCmdShow
def hide_taskbar():
hWnd = user32.FindWindowW(u"Shell_traywnd", None)
user32.ShowWindow(hWnd, SW_HIDE)
hWnd_btn_start = user32.FindWindowW(u"Button", 'Start')
user32.ShowWindow(hWnd_btn_start, SW_HIDE)
def unhide_taskbar():
hWnd = user32.FindWindowW(u"Shell_traywnd", None)
user32.ShowWindow(hWnd, SW_SHOW)
if (HIDE):
hide_taskbar();
else:
unhide_taskbar();
Usage:
To show the taskbar python hideTaskBar.py Show
To hide the taskbar python hideTaskBar.py Hide
Again, many thanks to @eryksun

Samuel Aiala Ferreira
- 654
- 6
- 11