How to pop-up minimized program at Taskbar python

点点圈 提交于 2020-06-16 09:39:27

问题


What I want to pop-up is minimized at taskbar.

But when I run below code, not minimized program pop-up, one more program run, and it cannot be clicked or seen and simply exists in the taskbar.

import win32gui, win32con


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

What I expected : minimized program pop-up

enter image description here


回答1:


Firstly make sure that you are locating the right window using this Finder tool. If you do not have Visual Studio, you can also download Winspector

Next, what you can try is to swap the arguments, for e.g

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

Arguments for .FindWindow is className followed by windowName which can be found here

Moreover, you can set specific flags for your window to show.

For example if the initial state is minimized, you can show it by using the SW_SHOWNORMAL flag. Usage is as such, 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.



来源:https://stackoverflow.com/questions/57471178/how-to-pop-up-minimized-program-at-taskbar-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!