pywin32

Writing a pandas dataframe to a word document table via pywin32

大兔子大兔子 提交于 2019-12-09 23:53:58
问题 I am currently working on a script that needs to write to a .docx file for presentation purposes. I use pandas to handle all my data calculations in the script. I am looking to write a pandas dataframe into a table at a bookmark in a word.docx file using PyWIN32. The dataframe consists of floats. The psuedo code is something like this. frame = DataFrame(np.arange(28).reshape((4,7)), columns=['Text1',...'Text7']) With pywin32 imported... wordApp = win32.gencache.EnsureDispatch('Word

Which is the best way to interact with already open native OS dialog boxes like (Save AS) using Python?

只谈情不闲聊 提交于 2019-12-09 00:03:41
问题 Is there any efficient way using any Python module like PyWind32 to interact with already existing Native OS dialog boxes like 'Save As' boxes? I tried searching on Google but no help. EDIT: 1: The Save As dialog box is triggered when user clicks on a Save As dialog box on a web application. 2: Any suggestion are welcome to handle any native OS dialog boxes which are already triggered using Python.(Need not be specific to Selenium webdriver, I am looking for a generic suggestion.) (When I was

How do I handle Python unicode strings with null-bytes the 'right' way?

只谈情不闲聊 提交于 2019-12-08 15:51:57
问题 Question It seems that PyWin32 is comfortable with giving null-terminated unicode strings as return values. I would like to deal with these strings the 'right' way. Let's say I'm getting a string like: u'C:\\Users\\Guest\\MyFile.asy\x00\x00sy' . This appears to be a C-style null-terminated string hanging out in a Python unicode object. I want to trim this bad boy down to a regular ol' string of characters that I could, for example, display in a window title bar. Is trimming the string off at

Pywin32 Saving as XLSM file instead of XLSX

£可爱£侵袭症+ 提交于 2019-12-08 11:52:25
问题 When I currently attempt to save an XLSM file like so: from win32com.client import Dispatch # Open Excel workbook xl = Dispatch("Excel.Application") wb = xl.Workbooks.Add(r"C:\Users\ryan\Desktop\Book1.xlsm") # Make some changes # blah blah blah # Save the workbook in XLSM format with new name wb.SaveAs(r"C:\Users\ryan\Desktop\Book1 - XLSM.xlsm") xl.Quit() I am given the following error... Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<COMObject Add>", line 7, in

Post-install errors while installing pywin32-216 on Windows XP

╄→гoц情女王★ 提交于 2019-12-08 09:54:37
问题 I'm using the pywin32-216.win32-py2.6.exe package to install pywin32 on Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32 . I am seeing the following post install errors. Could someone help me understand what going wrong? Thanks in advance. Copied pythoncom26.dll to C:\WINDOWS\system32\pythoncom26.dll Copied pythoncomloader26.dll to C:\WINDOWS\system32\pythoncomloader26.dll Copied pywintypes26.dll to C:\WINDOWS\system32\pywintypes26.dll FAILED to register

Having several issues with a Python service for Windows

烂漫一生 提交于 2019-12-08 08:49:30
问题 I've checked at least a couple of dozen of similar cases to mine and still haven't come up with a solution, I hope someone can shed some light, there's gotta be something I'm missing here. I'm using Python3.6 to make a Windows service, the service has to run a .exe file if it's not running. Here's the .py: import win32service import win32serviceutil import win32api import win32con import win32event import win32evtlogutil import psutil import subprocess import os, sys, string, time import

How to launch win32 applications in separate threads in Python

北城余情 提交于 2019-12-08 07:37:48
问题 So, I am having this following snippet which attempts to start Microsoft Powerpoint through the win32api: import threading import win32com.client import sys class myDemo(threading.Thread): def __init__(self): threading.Thread.__init__(self) def run(self): try: myObject = win32com.client.Dispatch("Powerpoint.Application") print "OK" except: print "Failed to start Powerpoint!" sys.exit(1) print "Now attempting to shutdown..." try: myObject.quit() except: print "Error" if __name__ == "__main__":

Python 'No module named win32gui' after installing pywin32

℡╲_俬逩灬. 提交于 2019-12-08 07:29:00
问题 Running python 3.6 on windows 8. ModuleNotFoundError: No module named 'win32gui' I have tried multiple installations of pywin32 but none have worked so far. https://sourceforge.net/projects/pywin32/files/pywin32/Build%20221/ goes through installation without problems but the issue persuades. Same with pip installing: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pywin32 In my Python root there is now multiple pywin32/win32 variants in the site-packages folder. pywin32.pth doesn't contain a

PyWin32 get network information/statistics

大憨熊 提交于 2019-12-08 05:38:00
问题 I am trying to get Network Statistics for my Windows 7 system using PyWin32 . The steps I followed: 1) Run COM MakePy utility and than select network list manager 1.0 type library under type library. 2) Above process generated this python file. Now the problem I am facing is after the above two steps what should be my next step . I tried a couple of things like: I copied the CLSID = IID('{DCB00000-570F-4A9B-8D69-199FDBA5723B}') line from the above generated python file and used it like >>>

press enter via python script

家住魔仙堡 提交于 2019-12-08 05:24:59
问题 We are trying to create a python script to install an app via windows shell prompt, executing our python script. We have an output prompt from the app.exe indicating "Press Enter to Continue..." We tried to simulate the Enter key but it doesn't work. The prompt just sits still not moving to the next wizard step. How do we overcome this problem? import subprocess import win32console APP_BIN = 'app.exe' def main(): proc = subprocess.Popen([APP_BIN,'-i','console'],stdin=subprocess.PIPE, stdout