python - python 如何在任务栏弹出最小化程序

标签 python python-3.x win32gui

我想要弹出的内容在任务栏最小化。

但是当我运行下面的代码时,没有最小化程序弹出窗口,又运行了一个程序,并且无法单击或看到它,只是存在于任务栏中。

import win32gui, win32con


hwnd = win32gui.FindWindow(None, "League of Legends")
win32gui.SetForegroundWindow(hwnd)
win32gui.ShowWindow(hwnd, win32con.SW_SHOW)

我所期望的:最小化程序弹出窗口

enter image description here

最佳答案

首先确保您使用此 Finder 找到正确的窗口工具。如果没有Visual Studio,也可以下载Winspector

接下来,您可以尝试交换参数,例如

hwnd = win32gui.FindWindow("League of Legends", None)

.FindWindow 的参数是 className 后跟 windowName,可以找到 here

此外,您还可以设置 specific flags让您的窗口显示。

例如,如果初始状态最小化,您可以使用 SW_SHOWNORMAL 标志来显示它。用法是这样的, win32gui.ShowWindow(hwnd, win32con.SW_SHOWNORMAL)

(SW_SHOW) Activates the window and displays it in its current size and position.

(SW_SHOWNORMAL) Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.

关于python - python 如何在任务栏弹出最小化程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57471178/

相关文章:

python-3.x - Pandas 按值和索引对 DF 进行排序

python - 在 Pycharm 中找不到 Openpyxl

c++ - `SetWindowLong()` 函数不执行 't change window style even after calling ` SetWindowPos()`

c++ - 如何初始化句柄

c++ - 在 Windows 10 中双击对话框窗口的顶部或底部边缘后如何阻止调整大小?

python - 使用协议(protocol) 2 : Python3->2 data 进行 pickle

python - mongodb 查询中的逻辑运算符与 python

python - cython-distutils 与 cmake : linking against libpython?

Python 在两个 QThread 之间发送信号

python - 所有特征必须在 [0, 9] 或 [-10, 0] 范围内