def _get_ctrl(criteria_): "Get the control based on the various criteria" # make a copy of the criteria criteria = [crit.copy() for crit in criteria_] # find the dialog dialog = controls.WrapHandle( findwindows.find_window(**criteria[0])) ctrl = None # if there is only criteria for a dialog then return it if len(criteria) > 1: # so there was criteria for a control, add the extra criteria # that are required for child controls ctrl_criteria = criteria[1] ctrl_criteria["top_level_only"] = False ctrl_criteria["parent"] = dialog.handle # resolve the control and return it ctrl = controls.WrapHandle( findwindows.find_window(**ctrl_criteria)) if ctrl: return (dialog, ctrl) else: return (dialog, )
def _get_ctrl(criteria_): "Get the control based on the various criteria" # make a copy of the criteria criteria = [crit.copy() for crit in criteria_] # find the dialog dialog = controls.WrapHandle(findwindows.find_window(**criteria[0])) ctrl = None # if there is only criteria for a dialog then return it if len(criteria) > 1: # so there was criteria for a control, add the extra criteria # that are required for child controls ctrl_criteria = criteria[1] ctrl_criteria["top_level_only"] = False ctrl_criteria["parent"] = dialog.handle # resolve the control and return it ctrl = controls.WrapHandle(findwindows.find_window(**ctrl_criteria)) if ctrl: return (dialog, ctrl) else: return (dialog, )
def connect_(self, **kwargs): "Connects to an already running process" connected = False if 'process' in kwargs: self.process = kwargs['process'] AssertValidProcess(self.process) connected = True elif 'handle' in kwargs: if not handleprops.iswindow(kwargs['handle']): message = "Invalid handle 0x%x passed to connect_()"% ( kwargs['handle']) raise RuntimeError(message) self.process = handleprops.processid(kwargs['handle']) connected = True elif 'path' in kwargs: self.process = process_from_module(kwargs['path']) connected = True elif kwargs: handle = findwindows.find_window(**kwargs) self.process = handleprops.processid(handle) connected = True if not connected: raise RuntimeError( "You must specify one of process, handle or path") return self
def connect_(self, **kwargs): "Connects to an already running process" connected = False if 'process' in kwargs: self.process = kwargs['process'] AssertValidProcess(self.process) connected = True elif 'handle' in kwargs: if not handleprops.iswindow(kwargs['handle']): message = "Invalid handle 0x%x passed to connect_()" % ( kwargs['handle']) raise RuntimeError(message) self.process = handleprops.processid(kwargs['handle']) connected = True elif 'path' in kwargs: self.process = process_from_module(kwargs['path']) connected = True elif kwargs: handle = findwindows.find_window(**kwargs) self.process = handleprops.processid(handle) connected = True if not connected: raise RuntimeError( "You must specify one of process, handle or path") return self