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?
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)
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With