在python(3.2)中隐藏Windows启动orb



我正在创建一个程序,它将取代Python中的windows开始菜单。我已经设法找到一种方法来隐藏任务栏如下所示,但我找不到一种方法来隐藏开始球体(Windows按钮)。

import ctypes
from ctypes import wintypes
FindWindow = ctypes.windll.user32.FindWindowA
FindWindow.restype = wintypes.HWND
FindWindow.argtypes = [
    wintypes.LPCSTR, #lpClassName
    wintypes.LPCSTR, #lpWindowName
]
SetWindowPos = ctypes.windll.user32.SetWindowPos
SetWindowPos.restype = wintypes.BOOL
SetWindowPos.argtypes = [
    wintypes.HWND, #hWnd
    wintypes.HWND, #hWndInsertAfter
    ctypes.c_int,  #X
    ctypes.c_int,  #Y
    ctypes.c_int,  #cx
    ctypes.c_int,  #cy
   ctypes.c_uint, #uFlags
] 
TOGGLE_HIDEWINDOW = 0x80
TOGGLE_UNHIDEWINDOW = 0x40
def hide_taskbar():
    handleW1 = FindWindow(b"Shell_traywnd", b"")
    SetWindowPos(handleW1, 0, 0, 0, 0, 0, TOGGLE_HIDEWINDOW)
def unhide_taskbar():
    handleW1 = FindWindow(b"Shell_traywnd", b"")
    SetWindowPos(handleW1, 0, 0, 0, 0, 0, TOGGLE_UNHIDEWINDOW)

您可以使用FindWindow和orb的类原子0xC017获得开始orb的句柄。然后使用ShowWindowSetWindowPos来隐藏任务栏和球体。例如:

import ctypes
from ctypes import wintypes
user32 = ctypes.WinDLL("user32")
SW_HIDE = 0
SW_SHOW = 5
START_ATOM = wintypes.LPCWSTR(0xC017) # i.e. MAKEINTATOM(...)
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():
    hWndTray = user32.FindWindowW(u"Shell_traywnd", None)
    user32.ShowWindow(hWndTray, SW_HIDE)
    hWndStart = user32.FindWindowW(START_ATOM, None)
    if hWndStart:
        user32.ShowWindow(hWndStart, SW_HIDE)
def unhide_taskbar():
    hWndTray = user32.FindWindowW(u"Shell_traywnd", None)
    user32.ShowWindow(hWndTray, SW_SHOW)
    hWndStart = user32.FindWindowW(START_ATOM, None)
    if hWndStart:
        user32.ShowWindow(hWndStart, SW_SHOW)

相关内容

  • 没有找到相关文章

最新更新