def getInnerHandle(self, handle): # cannot get the correct "inner handle" return nextHndle = handle user32 = ctypes.windll.user32 # controls = mf.findControls(handle, wantedClass="Scintilla") print 'Scintilla controls: %s' % controls for c in controls: ln = self.getCurrentLineNumber(c) numberLines = self.getNumberOfLines(c) visible1 = self.isVisible(c) info = win32gui.GetWindowPlacement(c) print 'c: %s, linenumber: %s, nl: %s, info: %s' % ( c, ln, numberLines, repr(info)) parent = c while 1: parent = win32gui.GetParent(parent) clName = win32gui.GetClassName(parent) visible = self.isVisible(parent) info = win32gui.GetWindowPlacement(parent) print 'parent: %s, class: %s, visible: %s, info: %s' % ( parent, clName, visible, repr(info)) if parent == handle: print 'at top' break
def getEditControl(self): # get application, if not found, set ctrl to None self.getAppWindow() if not self.app: self.__class__.ctrl = None return if tester == 'pythonwin': wTitle = win32gui.GetWindowText(self.app) filename = wTitle.split( '[')[-1][:-1] # remove [ and ], leaving only the filenam def selectionFunction(hndle, gotTitle, gotClass): """special for selecting the Afx class with the same title as the complete window title bar being the filename in question special for pythonwin and only for the FIRST search action for child windows. After the correct Afx window has been identified, the Scintilla child window is the correct one. """ if gotTitle == filename: #print 'got afx with title: %s'% gotTitle return True else: selectionFunction = None currentSel = None if self.ctrl: currentSel = mess.getSelection(self.ctrl) if currentSel and currentSel != (0, 0): return wC, wT = W["editcontrol"], W["edittext"] choiceControl = 0 if type(wT) in [type(None), bytes, int]: wT = [wT] if type(wC) in [type(None), bytes, int]: wC = [wC] ctrl = self.app for wtext, wclass in zip(wT, wC): ctrls = mess.findControls(ctrl, wantedText=wtext, wantedClass=wclass, selectionFunction=selectionFunction) if selectionFunction: selectionFunction = None # execute only for first findControls action pythonwin if tester == 'pythonwin': choiceControl = -1 if len(ctrls): ctrl = ctrls[choiceControl] #print 'editHndle set to: %s'% editHndle if len(ctrls) > 1: for hndle in ctrls: id = win32gui.GetDlgCtrlID(hndle) if id == 0xd6: ctrl = hndle break else: pprint.pprint(mess.dumpWindow(self.app)) raise ValueError( "could not find the editHndle of the control: %s in application: %s" % (self.editcontrol, self.apppath)) self.__class__.ctrl = ctrl self.__class__.classname = win32gui.GetClassName(ctrl)
def getEditControl(self, prog, appHndle): """get the control (self.ctrl) of the text window in the foreground prog = name of application (to be defined in self.WindowsParameters) appHndle = hndle of the application """ # get application, if not found, set ctrl to None currentSel = None if self.ctrl: currentSel = mess.getSelection(self.ctrl) if currentSel and currentSel != (0, 0): return # get controls via messages functions, elaborate here if we need client-server trick: W = self.WindowsParameters[prog] # test case with fixed handle, set in windowparameters.py: if W["controlhandle"]: self.ctrl = W["controlhandle"] return wantedText, wantedClass, selectionFunction = W["edittext"], W[ "editcontrol"], W["selectionfunction"] print 'wantedText: "%s", wantedClass: "%s", selectionFunction: %s' % ( wantedText, wantedClass, selectionFunction) ctrls = mess.findControls( appHndle, wantedText, wantedClass, selectionFunction) # pass the relevant windows parameters, as dict print 'ctrls for "%s": %s' % (prog, ctrls) # some special triggering in a difficult case: if ctrls: editHndle = ctrls[0] self.ctrl = editHndle else: self.ctrl = None
def getInnerHandle(self, handle): controls = mf.findControls(handle, wantedClass="Scintilla") print 'Scintilla controls: %s' % controls for c in controls: ln = self.getCurrentLineNumber(c) numberLines = self.getNumberOfLines(c) visible1 = mf.isVisible(c) print 'c: %s, linenumber: %s, nl: %s, visible: %s' % ( c, ln, numberLines, visible1)
def getInnerHandle(self, handle): """procedure to get inner handle for EditControl, via a control that holds the filename, which is extracted from the window title """ title = win32gui.GetWindowText(handle) #print 'title: %s'% title tabName = title.split(']')[0] tabName = tabName.split('[')[-1] self.prevTabName = tabName #print 'tabName: %s'% tabName controls = mf.findControls(handle, wantedText=tabName) if not controls: #print 'uedit32Actions, no control with title: "%s" found'% tabName return if len(controls) > 1: print 'uedit32Actions, strange, found more controls, matching the title: "%s", take first' % tabName c = controls[0] innerControl = mf.findControls(c, wantedClass="EditControl")[0] return innerControl
def getInnerHandle(self, handle): findValues = mf.findControls(handle, wantedClass="RichEdit20A") if findValues: return findValues[0]