I am having problems with FindWindow using the pywin32 extension. Simple C code:
int main() { HWND h = FindWindow(NULL, TEXT("SomeApp")); if (h != INVALID_HANDLE_VALUE) SetForegroundWindow(h); return 0; }
It works well. Same thing with python:
import win32gui h = win32gui.FindWindow(None, "SomeApp") if h: win32gui.SetForegroundWindow(h) else: print "SomeApp not found"
Failed, SomeApp not found. I suggest that text encoding can cause problems here, but does not find any information in the documents how to specify the text.
Update: I tested the code on another machine and do not see any problems. So the configuration on my first machine should be wrong. When a problem is detected, I update the results of my research.
source share