i'm working on a plugin, in that plugin i want to check if excel is running
here is my code for so far:
Code: Select all
class ifExcelIsRunning(eg.ActionBase):
def __call__(self):
eg.globals.Excel_Check="false"
eg.globals.ActiveMacro="Excel"
alOpen=eg.plugins.Window.FindWindow(u'EXCEL.EXE', None, None, None, None, None, False, 0.0, 0)
print alOpen
print eg.plugins.Window.BringToFront()
eg.plugins.MyNewPlugin.LogFileHandler("Excel is al geopend!")
import win32gui
Check_if_open = win32gui.MessageBox(0, "Error: \\nin order to run this marco successfully \\nyou need to close all open excel projects, \n\n do you want to close Excel now?", "Warning!!!!", 1)
if Check_if_open == 1:
eg.plugins.MyNewPlugin.LogFileHandler("Excel Word gesloten")
eg.globals.Excel_Check="true"
eg.plugins.Window.FindWindow(u'EXCEL.EXE', None, None, None, None, None, False, 0.0, 0)
eg.plugins.Window.BringToFront()
eg.plugins.Window.Close()
win32gui.MessageBox(0, "Kies eerst of u het bestand wilt opslaan, en klik daarna pas hier verder!!", "Warning!!!!", 1)
if eg.globals.Excel_Check == "false":
eg.plugins.EventGhost.TriggerEvent(u'Excel_Vars', 0.0)
else:
print "wacht op antwoord, sluit excel?"
eg.plugins.MyNewPlugin.LogFileHandler("File found moving on to the next action")
eg.plugins.EventGhost.TriggerEvent(u'Excel_Check', 0.0)
when FindWindows didn't find the window cancel this action.
if i edit the this action in eventghost, there is a option for this but this doesn't work if i use it in a plugin
am i doing something wrong or is there another check if FindWindow is true or false?
i already tryed things like:
Code: Select all
eg.globals.ActiveMacro="Excel"
alOpen=eg.plugins.Window.FindWindow(u'EXCEL.EXE', None, None, None, None, None, True, 0.0, 0)
print alOpen
print eg.plugins.Window.BringToFront()Who can help me with my problem ?
Thanks in advanced!