def setUp(self): """Start the application set some data and ensure the application is in the state we want it.""" self.texts = ['Tooltip Tool 0', 'Tooltip Tool 1', 'Tooltip Tool 2'] # start the application from pywinauto.application import Application app = Application() app.start_(controlspy_folder + "Tooltip.exe") self.app = app self.dlg = app.MicrosoftControlSpy tips = app.windows_(visible_only=False, enabled_only=False, top_level_only=False, class_name="tooltips_class32") self.ctrl = WrapHandle(tips[1])
class ToolTipsTestCases(unittest.TestCase): "Unit tests for the tooltips class" def setUp(self): """Start the application set some data and ensure the application is in the state we want it.""" self.texts = ['Tooltip Tool 0', 'Tooltip Tool 1', 'Tooltip Tool 2'] # start the application from pywinauto.application import Application app = Application() app.start_(controlspy_folder + "Tooltip.exe") self.app = app self.dlg = app.MicrosoftControlSpy tips = app.windows_(visible_only=False, enabled_only=False, top_level_only=False, class_name="tooltips_class32") self.ctrl = WrapHandle(tips[1]) #self.ctrl = HwndWrapper(tips[1]) #self.dlg.MenuSelect("Styles") # select show selection always, and show checkboxes #app.ControlStyles.ListBox1.TypeKeys( # "{HOME}{SPACE}" + "{DOWN}"* 12 + "{SPACE}") #self.app.ControlStyles.ApplyStylesSetWindowLong.Click() #self.app.ControlStyles.SendMessage(win32defines.WM_CLOSE) def tearDown(self): "Close the application after tests" # close the application self.dlg.SendMessage(win32defines.WM_CLOSE) def testFriendlyClass(self): "Make sure the friendly class is set correctly" self.assertEquals(self.ctrl.FriendlyClassName(), "ToolTips") def testTexts(self): "Make sure the texts are set correctly" self.assertEquals(self.ctrl.Texts()[1:], self.texts) def testGetProperties(self): "Test getting the properties for the tooltips control" props = self.ctrl.GetProperties() self.assertEquals(self.ctrl.FriendlyClassName(), props['FriendlyClassName']) self.assertEquals(self.ctrl.Texts(), props['Texts']) for prop_name in props: self.assertEquals( getattr(self.ctrl, prop_name)(), props[prop_name]) def testGetTip(self): self.assertRaises(IndexError, self.ctrl.GetTip, 99) tip = self.ctrl.GetTip(1) self.assertEquals(tip.text, self.texts[1]) def testToolCount(self): self.assertEquals(3, self.ctrl.ToolCount()) def testGetTipText(self): self.assertEquals(self.texts[1], self.ctrl.GetTipText(1)) def testTexts(self): self.assertEquals(self.ctrl.Texts()[0], '') self.assertEquals(self.ctrl.Texts()[1:], self.texts)
prev_height = app.Attributes.Edit2.Texts()[1] # set our preferred area app.Attributes.Edit1.TypeKeys("350") # you can use TypeKeys or app.Attributes.Edit2.SetEditText("350") # SetText - they work differently! app.Attributes.OK.CloseClick() try: # get the reference to the Canvas window canvas = pwin.Afx100000008 canvas.WrapperObject() except WindowAmbiguousError as e: print(e, e.windows) for w in e.windows: w = WrapHandle(w) print(w.WindowText(), w.Class()) import sys sys.exit() # make sure the pencil tool is selected pwin.Tools2.Click(coords=(91, 16)) size = 15 num_slants = 20 # draw the axes canvas.PressMouse(coords=(size, size * num_slants)) canvas.MoveMouseInput(coords=(size * num_slants, size * num_slants)) canvas.MoveMouseInput(coords=(size * num_slants, size)) canvas.ReleaseMouse()