'pywintypes.error: (0, 'SetForegroundWindow', 'No error message is available')

When using this code:

handle = win32gui.FindWindow(0, "Notepad")
win32gui.SetForegroundWindow(handle) ## put the window in foreground

I get this error:

*pywintypes.error: (0, 'SetForegroundWindow', 'No error message is available')*

Tried to read all the post about this, but none fixes the problem.. any hints ?

Running on windows 10



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source