2

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

Siong Thye Goh
  • 3,518
  • 10
  • 23
  • 31
4rigener
  • 346
  • 3
  • 18

1 Answers1

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.

Community
  • 1
  • 1
Axois
  • 1,961
  • 2
  • 11
  • 22
  • If program not be minimized just behind other windows, then my code work normally. – 4rigener Aug 13 '19 at 08:03
  • Use other flags such as `SW_SHOWNORMAL` – Axois Aug 13 '19 at 09:29
  • That's samse as SW_SHOW – 4rigener Aug 13 '19 at 10:22
  • I search google for 12 hours, but i can't find what i expected. And I'm korean. There's no korea documents, and I'm not familiar with english. I just 23. Sorry, I can't understand specific flags with my situation – 4rigener Aug 13 '19 at 11:58
  • If you would like your minimized program to pop up from its minimized state, instead of using `win32gui.ShowWindow(hwnd, win32con.SW_SHOW)` use `win32gui.ShowWindow(hwnd, win32con.SW_SHOWNORMAL)` – Axois Aug 13 '19 at 12:42
  • Now I experiment with notepad, and It works find..... But why League of Legends not pop-up, and another can't see process created like picture – 4rigener Aug 13 '19 at 12:57
  • Okay. Honestly its a little bit difficult to help you because of the language barrier here. But what I suspect is that your "League of Legends" is probably not the right class name. To find the CORRECT class name you will have to download an external application like Winspector to find the class name. Then you use `hwnd = win32gui.FindWindow("class name here", None)` – Axois Aug 13 '19 at 13:06