Python中设置指定窗口为前台活动窗口(最顶层窗口)win32gui
参考链接:Python中设置指定窗口为前台活动窗口(最顶层窗口)win32gui: https://blog.csdn.net/bailichun19901111/article/details/105042145
Win32 API之EnumWindows详解: http://blog.sina.com.cn/s/blog_e5f00a490101w1yc.html
测试1:SetForegroundWindow修改活动。
#
# 输出当前活动窗体句柄
#
def print_GetForegroundWindow():
hwnd_active = win32gui.GetForegroundWindow()
print(‘hwnd_active hwnd:‘,hwnd_active)
print(‘hwnd_active text:‘,win32gui.GetWindowText(hwnd_active))
print(‘hwnd_active class:‘,win32gui.GetClassName(hwnd_active))

![Python中设置指定窗口为前台活动窗口(最顶层窗口)win32gui
[编程语言教程]](https://www.zixueka.com/wp-content/uploads/2024/01/1706714662-e420e9bde24ea30.jpg)
