win32com

Windows: How to simulate connected screen via VGA

落爺英雄遲暮 提交于 2019-12-11 11:00:02
问题 I am trying to make a screen capturing service. I have a physical PC and I would like to run a program that displays a document (ex. MSWord) and then take a screenshot. Problem is that if I use using (var bitmap = new Bitmap(p.EndX - p.StartX, p.EndY - p.StartY)) { using (Graphics g = Graphics.FromImage(bitmap)) { g.CopyFromScreen(p.StartX, p.StartY, 0, 0, p.EndX,p.EndY,new Size(p.EndX - p.StartX, p.EndY - p.StartY)); } bitmap.Save("result.png", ImageFormat.Png); } it works only if I have a

CreateProcessAsUser done! How to control the created process?

落花浮王杯 提交于 2019-12-11 10:10:25
问题 I'm trying to launch an app as another user, this works perfectly, the process is created, but I don't know how to handle the created process as I usually do with comtypes or win32com (COM interface), here is the script: import win32process import win32security import win32con import cgi import cgitb; cgitb.enable() domain = '.' username = 'me' password = 'mypwd' try: token = win32security.LogonUser ( username, domain, password, win32security.LOGON32_LOGON_NETWORK, win32security.LOGON32

Python - Using win32com.client to accept all changes in Word Documents

余生颓废 提交于 2019-12-11 10:09:43
问题 I'm using win32com.client from the pywin32 module to accept all tracked changes in a word document (Python 3.6.4 on Windows 10 64 bit). Specifically the code I'm using is the following: import win32com.client as win32 word = win32.gencache.EnsureDispatch("Word.Application") word.Visible = False doc = word.Documents.Open(PATH TO WORD FILE) doc.Activate() word.ActiveDocument.TrackRevisions = False # Maybe not need this try: word.WordBasic.AcceptAllChangesInDoc() except TypeError: pass word

win32com module not found

懵懂的女人 提交于 2019-12-11 04:38:40
问题 I am trying to get pyttsx3 up and running on my computer. I did pip install pyttsx3 and pip install pypiwin32 I can see both of them in my python directory. I type this code in to test it: import pyttsx3 engine = pyttsx3.init() engine.say("I will speak this text") engine.runAndWait() This is what comes out: Traceback (most recent call last): File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3__init__.py", line 44, in init eng = _activeEngines[driverName] File

Choosing “From” field using python win32com outlook

删除回忆录丶 提交于 2019-12-11 03:06:32
问题 I am trying to automate emails using python. Unfortunately, the network administrators at my work have blocked SMTP relay, so I cannot use that approach to send the emails (they are addressed externally). I am therefore using win32com to automatically send these emails via outlook. This is working fine except for one thing. I want to choose the "FROM" field within my python code, but I simply cannot figure out how to do this. Any insight would be greatly appreciated. 回答1: If you configured a

Cannot open Visio document with Python

女生的网名这么多〃 提交于 2019-12-11 02:34:39
问题 I am attempting to do some automation in Visio using Python. I am able to open the Visio application and create a new document, but cannot open an existing document. Here is the code that I am trying. import win32com.client visio = win32com.client.Dispatch("Visio.Application") # this works doc = visio.Documents.Open("C:\Users\username\test.vsd") # nope The error I get back is Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<COMObject <unknown>>", line 3, in OpenEx

getting underlying OLE object identity for win32com automation objects

风流意气都作罢 提交于 2019-12-10 21:23:45
问题 Most built-in Python data types and libraries make a point of returning the same object ( a is b , not just a==b ) even if you ask for it in different ways. A very simple example: list = [ "foo", "bar", {"name": [1,2,3]} ] a = list[-1]["name"] b = list[2].values()[0] print (a is b) # True! However, this doesn't seem to be the case for many kinds of non-scalar objects returned by win32com automation. The following code connects to sas-jmp automation and then gets two handles to the same data

COM “get property” with multiple arguments

你离开我真会死。 提交于 2019-12-10 15:12:39
问题 I'm trying to call WindowsInstaller.Installer.ProductsEx from python, and can't figure out how to make it work. Here's a vbscript version of what I want to call from python: dim msi, products set msi = CreateObject("WindowsInstaller.Installer") set products = msi.ProductsEx("", "s-1-1-0", 7) I think my issue is ProductsEx is a read-only get property that takes 3 arguments, and I don't know how to convince win32com or comtypes to call it that way. I tried: >>> import win32com.client >>> msi =

Python win32com don't know name of module

自作多情 提交于 2019-12-10 14:39:04
问题 I was looking for a python Zune(The windows media thing) api, when I looked at the COM browser in pythonwin. I found something called ZuneWmdu Type Library (1.0). I used makepy on that lib, it generated a file 9FE20C05-81CE-46D7-9C56-FD97A865BBB8x0x1x0.py in python 2.7.3\Lib\site-packages\win32com\gen_py I have no idea what to pass into win32com.client.gencache.EnsureDispatch('???') I tried calling win32com.client.gencache.EnsureDispatch('9FE20C0581CE46D79C56FD97A865BBB8') Resulting in an

Write and execute excel VB macro with win32com.client

冷暖自知 提交于 2019-12-10 11:19:31
问题 I am attempting to write a script that opens an existing .xlsx file, writes a Visual Basic macro script to auto-size comments, executes said macro, then closes and saves the workbook. I am quite unfamiliar with win32com.client, and after several hours of digging I have not found good documentation for writing VB macro scripts from python. Therefore, I stitched together a script using feedback from these threads: https://stackoverflow.com/a/19506287/7547876 https://stackoverflow.com/a/2141981