python 将一个外部窗口的边框设置为不可调节
要将一个外部窗口的边框设置为不可调节,可以使用ctypes模块调用Windows API函数来实现。以下是一个示例代码:
import ctypes
# 获取窗口句柄
hwnd = ctypes.windll.user32.GetForegroundWindow()
# 设置窗口样式为不可调节边框
style = ctypes.windll.user32.GetWindowLongW(hwnd, ctypes.c_int(-16))
style = style & ~0x00040000 # WS_SIZEBOX
ctypes.windll.user32.SetWindowLongW(hwnd, ctypes.c_int(-16), ctypes.c_long(style))
# 刷新窗口
ctypes.windll.user32.SetWindowPos(hwnd, 0, 0, 0, 0, 0, 0x0001 | 0x0002 | 0x0020)
请注意,此代码只适用于Windows操作系统。如果你使用的是其他操作系统,可能需要使用不同的方法来实现。
原文地址: https://www.cveoy.top/t/topic/i4f4 著作权归作者所有。请勿转载和采集!