comtypes

COM object VARIANT parameters in comtypes (python)

纵饮孤独 提交于 2021-02-09 11:42:13
问题 I am trying to use comtypes 1.1.0 package to access COM object within python 2.7.6.1 and I have a basic problem to get correct data from COM object method due to return VARIANT type >>> from comtypes.client import CreateObject >>> fm1 = CreateObject("MCB.PCM") >>> fm1.ReadVariable("dwt") (<comtypes.automation.LP_tagVARIANT object at 0x06A541C0>,<comtypes.automation.LP_tagVARIANT object at 0x06A54210>, <comtypes.automation.LP_tagVARIANT object at 0x06A54260>, True) How to convert VARIANT

COM object VARIANT parameters in comtypes (python)

蹲街弑〆低调 提交于 2021-02-09 11:42:11
问题 I am trying to use comtypes 1.1.0 package to access COM object within python 2.7.6.1 and I have a basic problem to get correct data from COM object method due to return VARIANT type >>> from comtypes.client import CreateObject >>> fm1 = CreateObject("MCB.PCM") >>> fm1.ReadVariable("dwt") (<comtypes.automation.LP_tagVARIANT object at 0x06A541C0>,<comtypes.automation.LP_tagVARIANT object at 0x06A54210>, <comtypes.automation.LP_tagVARIANT object at 0x06A54260>, True) How to convert VARIANT

How to use COM from python win32com or comtypes to access an IRTDServer?

萝らか妹 提交于 2021-02-07 20:10:29
问题 Environment Windows 10 + python 3.6.3 64 bit (also tried 32 bit). I am a python developer trying to use COM for (nearly) the first time and hit this huge blocker. Problem I have had various errors when trying to use an IRTDServer implemented in a dll (not written by me), via either win32com or comtypes . Using win32com turned out to be more difficult. I have an included an example unittest for both libraries below. Accessing the server from Excel 2016 works as expected; this returns the

How to use COM from python win32com or comtypes to access an IRTDServer?

情到浓时终转凉″ 提交于 2021-02-07 20:00:44
问题 Environment Windows 10 + python 3.6.3 64 bit (also tried 32 bit). I am a python developer trying to use COM for (nearly) the first time and hit this huge blocker. Problem I have had various errors when trying to use an IRTDServer implemented in a dll (not written by me), via either win32com or comtypes . Using win32com turned out to be more difficult. I have an included an example unittest for both libraries below. Accessing the server from Excel 2016 works as expected; this returns the

Python Visio to pdf

一世执手 提交于 2020-04-14 06:06:10
问题 I'm trying to convert a bunch of Visio files to pdf in python. I have referenced this .doc to pdf using python and written the following code: import comtypes.client as coms format=17 visio = coms.CreateObject('Visio.Application') doc = visio.Documents.Open('map.vsd') doc.SaveAs('map.pdf', FileFormat=format) gives me a TypeError: call takes exactly 2 arguments (3 given) I've been Googling and can't find the reference on how to print to pdf in Visio using python. 回答1: You should use

Python win32com.client.Dispatch looping through Word documents and export to PDF; fails when next loop occurs

不想你离开。 提交于 2020-01-12 05:51:31
问题 Based on the script here: .doc to pdf using python I've got a semi-working script to export .docx files to pdf from C:\Export_to_pdf into a new folder. The problem is that it gets through the first couple of documents and then fails with: (-2147352567, 'Exception occurred.', (0, u'Microsoft Word', u'Command failed', u'wdmain11.chm', 36966, -2146824090), None) This, apparently is an unhelpful general error message. If I debug slowly it using pdb, I can loop through all files and export

How to create a .cdx file from InChI with ChemDraw/Python?

我是研究僧i 提交于 2020-01-05 04:17:18
问题 I would like to create a ChemDraw .cdx file from an InChI with Python. This answer gives a solution for cdx --> InChI . The minimal example below cdx_to_inchi works fine, but I could not figure out how I can get inchi_to_cdx to work. import comtypes.client as w32 def cdx_to_inchi(cdx): ChemDraw = w32.CreateObject("ChemDraw.Application") ChemDraw.Visible = False Compound = ChemDraw.Documents.Open(cdx) # opens existing file inchi = Compound.Objects.Data("chemical/x-inchi") print(inchi) ChemDraw

Windows authentication code no longer working now

社会主义新天地 提交于 2019-12-29 09:18:26
问题 My below code for windows authentication was working well for over a year. But for the last few days it is longer working now. I am not able to identify exact reason for that. from selenium import webdriver import time import win32com.client driver=webdriver.Chrome('D:/Software/BrowsersDriver/ChromeDriver/chromedriver.exe') driver.maximize_window() driver.get("authentication windows url") shell = win32com.client.Dispatch("WScript.Shell") shell.Sendkeys("username") time.sleep(1) shell.Sendkeys

Can't import comtypes.gen

半城伤御伤魂 提交于 2019-12-22 08:40:31
问题 I have comtypes 0.6.2 installed on Python 2.6. If I try this: import comtypes.gen I get: Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> import comtypes.gen ImportError: No module named gen Other imports like import comtypes and import comtypes.client , however, work fine. What am I doing wrong? From the name it seems comtypes.gen is generated code? If so, do I need certain preparatory steps before importing? I'm not logged in as administrator. Could that cause code

Retrieve output parameters from an AutoCAD API method in python

回眸只為那壹抹淺笑 提交于 2019-12-20 07:16:22
问题 I'm trying to retrieve 2 output Arrays from an XRecord in AutoCAD 2016 using python 2.7, with comtypes imported, the first array is an array of integers (DXF Group Codes) and the second array is an array of variants (the values of XRecord). The opposite way of what this question seeks to The method of interest is GetXRecordData , which (according to AutoCAD's documentation) if successful returns None , and only accepts 2 output arguments . when I try to retrieve it with code like DxfGrCd = []