当前位置: 首页>>代码示例>>Python>>正文


Python win32com.client方法代码示例

本文整理汇总了Python中win32com.client方法的典型用法代码示例。如果您正苦于以下问题:Python win32com.client方法的具体用法?Python win32com.client怎么用?Python win32com.client使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在win32com的用法示例。


在下文中一共展示了win32com.client方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import win32com [as 别名]
# 或者: from win32com import client [as 别名]
def __init__(self, logPath, mainWindow):
        super().__init__(logPath, mainWindow)
        self.log = open(logPath, 'r', encoding="utf8")
        self.log.readline()
        self.log.readline()
        characterLine = self.log.readline()
        self.character, self.language = ProcessCharacterLine(characterLine)
        logging.info('Log language is ' + self.language)
        self.log.readline()
        self.log.readline()
        self.logLine = self.log.readline()
        if (self.logLine == "------------------------------------------------------------\n"):
            self.log.readline()
            collisionCharacter, language = ProcessCharacterLine(self.log.readline())
            logging.error('Log file collision on characters' + self.character + " and " + collisionCharacter)
            messagebox.showerror("Error", "Log file collision on characters:\n\n" + self.character + " and " + collisionCharacter +
                                "\n\nThis happens when both characters log in at exactly the same second.\n" + 
                                "This makes it impossible to know which character owns which log.\n\n" + 
                                "Please restart the client of the character you want to track to use this program.\n" + 
                                "If you already did, you can ignore this message, or delete this log file:\n" + logPath)
            raise BadLogException("log file collision")
        self.log.read()
        self.compileRegex() 
开发者ID:ArtificialQualia,项目名称:PyEveLiveDPS,代码行数:25,代码来源:logreader.py

示例2: GetGeneratePath

# 需要导入模块: import win32com [as 别名]
# 或者: from win32com import client [as 别名]
def GetGeneratePath():
	"""Returns the name of the path to generate to.
	Checks the directory is OK.
	"""
	assert not is_readonly, "Why do you want the genpath for a readonly store?"
	try:
		os.makedirs(win32com.__gen_path__)
		#os.mkdir(win32com.__gen_path__)
	except os.error:
		pass
	try:
		fname = os.path.join(win32com.__gen_path__, "__init__.py")
		os.stat(fname)
	except os.error:
		f = open(fname,"w")
		f.write('# Generated file - this directory may be deleted to reset the COM cache...\n')
		f.write('import win32com\n')
		f.write('if __path__[:-1] != win32com.__gen_path__: __path__.append(win32com.__gen_path__)\n')
		f.close()
	
	return win32com.__gen_path__

#
# The helpers for win32com.client.Dispatch and OCX clients.
# 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:27,代码来源:gencache.py

示例3: Dispatch

# 需要导入模块: import win32com [as 别名]
# 或者: from win32com import client [as 别名]
def Dispatch(dispatch):
        return win32com.client.Dispatch(dispatch) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:4,代码来源:adodbapi.py

示例4: EnsureDispatch

# 需要导入模块: import win32com [as 别名]
# 或者: from win32com import client [as 别名]
def EnsureDispatch(prog_id, bForDemand = 1): # New fn, so we default the new demand feature to on!
	"""Given a COM prog_id, return an object that is using makepy support, building if necessary"""
	disp = win32com.client.Dispatch(prog_id)
	if not disp.__dict__.get("CLSID"): # Eeek - no makepy support - try and build it.
		try:
			ti = disp._oleobj_.GetTypeInfo()
			disp_clsid = ti.GetTypeAttr()[0]
			tlb, index = ti.GetContainingTypeLib()
			tla = tlb.GetLibAttr()
			mod = EnsureModule(tla[0], tla[1], tla[3], tla[4], bForDemand=bForDemand)
			GetModuleForCLSID(disp_clsid)
			# Get the class from the module.
			import CLSIDToClass
			disp_class = CLSIDToClass.GetClass(str(disp_clsid))
			disp = disp_class(disp._oleobj_)
		except pythoncom.com_error:
			raise TypeError("This COM object can not automate the makepy process - please run makepy manually for this object")
	return disp 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:20,代码来源:gencache.py

示例5: TestAll

# 需要导入模块: import win32com [as 别名]
# 或者: from win32com import client [as 别名]
def TestAll():
    TestWord()

    print "Starting Excel for Dynamic test..."
    xl = win32com.client.dynamic.Dispatch("Excel.Application")
    TextExcel(xl)

    try:
        print "Starting Excel 8 for generated excel8.py test..."
        mod = gencache.EnsureModule("{00020813-0000-0000-C000-000000000046}", 0, 1, 2, bForDemand=1)
        xl = win32com.client.Dispatch("Excel.Application")
        TextExcel(xl)
    except ImportError:
        print "Could not import the generated Excel 97 wrapper"

    try:
        import xl5en32
        mod = gencache.EnsureModule("{00020813-0000-0000-C000-000000000046}", 9, 1, 0)
        xl = win32com.client.Dispatch("Excel.Application.5")
        print "Starting Excel 95 for makepy test..."
        TextExcel(xl)
    except ImportError:
        print "Could not import the generated Excel 95 wrapper" 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:25,代码来源:testMSOffice.py

示例6: eval

# 需要导入模块: import win32com [as 别名]
# 或者: from win32com import client [as 别名]
def eval(self, expression, identify_erros=True):
    """ Evaluates a matlab expression synchronously.

    If identify_erros is true, and the last output line after evaluating the
    expressions begins with '???' an excpetion is thrown with the matlab error
    following the '???'.
    The return value of the function is the matlab output following the call.
    """
    #print expression
    self._check_open()
    ret = self.client.Execute(expression)
    #print ret
    if identify_erros and ret.rfind('???') != -1:
      begin = ret.rfind('???') + 4
      end = ret.find('\n', begin)
      raise MatlabError(ret[begin:end])
    return ret 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:19,代码来源:matlabcom.py

示例7: checkWriteCoClassBaseClass

# 需要导入模块: import win32com [as 别名]
# 或者: from win32com import client [as 别名]
def checkWriteCoClassBaseClass(self):
    if not self.bHaveWrittenCoClassBaseClass:
      print >> self.file, "from win32com.client import CoClassBaseClass"
      self.bHaveWrittenCoClassBaseClass = 1 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:genpy.py

示例8: _get_good_ret

# 需要导入模块: import win32com [as 别名]
# 或者: from win32com import client [as 别名]
def _get_good_ret(ob,
				  # Named arguments used internally
				  resultCLSID = None):
	assert resultCLSID is None, "Now have type info for ADSI objects - fix me!"
	# See if the object supports IDispatch
	if hasattr(ob, "Invoke"):
		import win32com.client.dynamic
		name = "Dispatch wrapper around %r" %  ob
		return win32com.client.dynamic.Dispatch(ob, name, ADSIDispatch)
	return ob 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:__init__.py

示例9: _wrap_dispatch_

# 需要导入模块: import win32com [as 别名]
# 或者: from win32com import client [as 别名]
def _wrap_dispatch_(self, ob, userName = None, returnCLSID = None, UnicodeToString=None):
		assert UnicodeToString is None, "this is deprectated and will be removed"
		if not userName:
			userName = "ADSI-object"
		olerepr = win32com.client.dynamic.MakeOleRepr(ob, None, None)
		return ADSIDispatch(ob, olerepr, userName) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:__init__.py

示例10: _NewEnum

# 需要导入模块: import win32com [as 别名]
# 或者: from win32com import client [as 别名]
def _NewEnum(self):
		try:
			return ADSIEnumerator(self)
		except pythoncom.com_error:
			# doesnt support it - let our base try!
			return win32com.client.CDispatch._NewEnum(self) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:__init__.py

示例11: __getattr__

# 需要导入模块: import win32com [as 别名]
# 或者: from win32com import client [as 别名]
def __getattr__(self, attr):
		try:
			return getattr(self._oleobj_, attr)
		except AttributeError:
			return win32com.client.CDispatch.__getattr__(self, attr) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:__init__.py

示例12: execute

# 需要导入模块: import win32com [as 别名]
# 或者: from win32com import client [as 别名]
def execute(self, operation, parameters=None):
        """Prepare and execute a database operation (query or command).
        
            Parameters may be provided as sequence or mapping and will be bound to variables in the operation.
            Variables are specified in a database-specific notation
            (see the module's paramstyle attribute for details). [5] 
            A reference to the operation will be retained by the cursor.
            If the same operation object is passed in again, then the cursor
            can optimize its behavior. This is most effective for algorithms
            where the same operation is used, but different parameters are bound to it (many times). 

            For maximum efficiency when reusing an operation, it is best to use
            the setinputsizes() method to specify the parameter types and sizes ahead of time.
            It is legal for a parameter to not match the predefined information;
            the implementation should compensate, possibly with a loss of efficiency. 

            The parameters may also be specified as list of tuples to e.g. insert multiple rows in
            a single operation, but this kind of usage is depreciated: executemany() should be used instead. 

            Return values are not defined.

            [5] The module will use the __getitem__ method of the parameters object to map either positions
            (integers) or names (strings) to parameter values. This allows for both sequences and mappings
            to be used as input. 
            The term "bound" refers to the process of binding an input value to a database execution buffer.
            In practical terms, this means that the input value is directly used as a value in the operation.
            The client should not be required to "escape" the value so that it can be used -- the value
            should be equal to the actual database value. 
        """
        self.messages=[]                
        self._executeHelper(operation,False,parameters) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:33,代码来源:adodbapi.py

示例13: SetSite

# 需要导入模块: import win32com [as 别名]
# 或者: from win32com import client [as 别名]
def SetSite(self,unknown):
        if unknown:
            # first get a command target
            cmdtarget = unknown.QueryInterface(axcontrol.IID_IOleCommandTarget)
            # then travel over to a service provider
            serviceprovider = cmdtarget.QueryInterface(pythoncom.IID_IServiceProvider)
            # finally ask for the internet explorer application, returned as a dispatch object
            self.webbrowser = win32com.client.Dispatch(serviceprovider.QueryService('{0002DF05-0000-0000-C000-000000000046}',pythoncom.IID_IDispatch))
        else:
            # lose all references
            self.webbrowser = None 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:iebutton.py

示例14: do_gen_child_item

# 需要导入模块: import win32com [as 别名]
# 或者: from win32com import client [as 别名]
def do_gen_child_item(self, oleitem):
    moduleDoc = self.typelib.GetDocumentation(-1)
    docDesc = ""
    if moduleDoc[1]:
      docDesc = moduleDoc[1]
    self.progress.Starting(docDesc)
    self.progress.SetDescription("Building definitions from type library...")
    self.do_gen_file_header()
    oleitem.WriteClass(self)
    if oleitem.bWritten:
        print >> self.file, 'win32com.client.CLSIDToClass.RegisterCLSID( "%s", %s )' % (oleitem.clsid, oleitem.python_name) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:genpy.py

示例15: TestWord

# 需要导入模块: import win32com [as 别名]
# 或者: from win32com import client [as 别名]
def TestWord():
    # Try and load the object exposed by Word 8
    # Office 97 - _totally_ different object model!
    try:
        # NOTE - using "client.Dispatch" would return an msword8.py instance!
        print "Starting Word 8 for dynamic test"
        word = win32com.client.dynamic.Dispatch("Word.Application")
        TestWord8(word)

        word = None
        # Now we will test Dispatch without the new "lazy" capabilities
        print "Starting Word 8 for non-lazy dynamic test"
        dispatch = win32com.client.dynamic._GetGoodDispatch("Word.Application")
        typeinfo = dispatch.GetTypeInfo()
        attr = typeinfo.GetTypeAttr()
        olerepr = win32com.client.build.DispatchItem(typeinfo, attr, None, 0)
        word = win32com.client.dynamic.CDispatch(dispatch, olerepr)
        dispatch = typeinfo = attr = olerepr = None
        TestWord8(word)

    except pythoncom.com_error:
        print "Starting Word 7 for dynamic test"
        word = win32com.client.Dispatch("Word.Basic")
        TestWord7(word)

    print "Starting MSWord for generated test"
    from win32com.client import gencache
    word = gencache.EnsureDispatch("Word.Application.8")
    TestWord8(word) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:31,代码来源:testMSOffice.py


注:本文中的win32com.client方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。