from win32com.client import Dispatch, GetActiveObject import pythoncom import threading class P4OFCCommand(threading.Thread): def __init__(self, menu_name): threading.Thread.__init__(self) self.menu_name = menu_name print 'thread created' def run(self): print 'running thread' pythoncom.CoInitialize() self.wd = GetActiveObject("Word.Application") self.wdapp = self.wd.Application self.p4menu = self.wdapp.CommandBars("P4OFCMenu") print self.p4menu.Name self.ctl = self.p4menu.Controls(self.menu_name) print self.ctl.Caption if not self.ctl.Enabled: self.ctl.Enabled = True self.ctl.Execute() print 'thread finished' pythoncom.CoUninitialize() def __del__(self): print 'thread is being destroyed' auto = Dispatch('AutoItX3.Control') try: wd = GetActiveObject("Word.Application") wd.Quit() except: pass wd = Dispatch('Word.Application') wdapp = wd p4menu = wdapp.CommandBars("P4OFCMenu") wdapp.Documents.Open(r'C:\work\p4ofc-test-local\fred-new1.doc') # ctl = p4menu.Controls("Perforce &information...") t = P4OFCCommand("&Document Status...") t.start() t = P4OFCCommand("Perforce &information...") t.start() # ctl.Execute() title = 'P4OFC - Perforce Connection Information' print "waiting window active" auto.WinWaitActive(title, '', 5) print "window active" auto.WinActivate(title, '') auto.Send("^a^c{ENTER}") info = auto.ClipGet() print info wdapp.Quit()
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 11314 | Robert Cowham | Initial population of perforce_software version of P4OFC | ||
//guest/robert_cowham/perforce/P4OFC/main/test/auto_test.py | |||||
#1 | 10843 | Robert Cowham |
Initial version of P4OFC source code. See README.txt (and LICENSE.txt and doc\P4OFC-Design.docx) |