I am trying to find if Microsoft excel has an open window
import win32ui
import time
def WindowExists(windowname):
try:
win32ui.FindWindow(None, windowname)
except win32ui.error:
return False
else:
return True
if WindowExists("filename - Microsoft Excel"):
print "Program is running"
time.sleep(10)
else:
print "Program is not running"
time.sleep(10)
this works if i enter the correct filename, but the thing is i dont know the filename. so how can i get this work when only knowing part of the title?
or must i search on the classname instead? if so how do i know the classname :)?
extra note: i do know the filename but it has a unknow number attached to it, something like filename88, and differs every time i run the program.