pywin32

Pulling data out of MS Word with pywin32

ぐ巨炮叔叔 提交于 2020-01-01 13:18:31
问题 I am running python 3.3 in Windows and I need to pull strings out of Word documents. I have been searching far and wide for about a week on the best method to do this. Originally I tried to save the .docx files as .txt and parse through using RE's, but I had some formatting problems with hidden characters - I was using a script to open a .docx and save as .txt. I am wondering if I did a proper File>SaveAs>.txt would it strip out the odd formatting and then I could properly parse through? I

Pulling data out of MS Word with pywin32

我与影子孤独终老i 提交于 2020-01-01 13:18:01
问题 I am running python 3.3 in Windows and I need to pull strings out of Word documents. I have been searching far and wide for about a week on the best method to do this. Originally I tried to save the .docx files as .txt and parse through using RE's, but I had some formatting problems with hidden characters - I was using a script to open a .docx and save as .txt. I am wondering if I did a proper File>SaveAs>.txt would it strip out the odd formatting and then I could properly parse through? I

ctypes: construct pointer from arbitrary integer

折月煮酒 提交于 2019-12-31 09:21:08
问题 For low-level purposes, I need to construct a ctypes pointer from an arbitrary address, given as an integer. For instance: INTP = ctypes.POINTER(ctypes.c_int) p = INTP(0x12345678) # i *know* this is the address But all such attempts result in TypeError: expected c_long instead of int Is there anything I can do to overcome this? In case someone wonders why I need this, it's done so as to extract the OVERLAPPED struct from a win32file.PyOVERLAPPED , for integrating ctypes-exposed functions with

How to simulate string keyboard input using Python?

依然范特西╮ 提交于 2019-12-30 13:59:30
问题 I'm using windows 8 and have the windows api module I am trying to create a method: TypeInput(argument) #argument is a string with the objective that my method simulates the typing of the argument if the argument is a string. Unfortunately, I currently simulate typing using: win32api.keybd_event(win32con.KEYCODE, MS KEYCODE, 0, 0) And i don't know how to abstract this so that I can plug in arbitrary characters. My initial guess was to do unicode conversions but it seems the problem is worse

Getting ActivePython to work with WSH

断了今生、忘了曾经 提交于 2019-12-30 04:33:30
问题 I've installed ActivePython 2.7.2 and I'm trying to execute a .pys script via the console with wscript/cscript, [i.e. ActivePython (PythonScript with .pys extension) in Microsoft's WSH(Windows Scripting Host)] and when trying with wscript I get two errors. "The program cannot start because MSVCR90.dll is missing from your computer try reinstalling the program to fix this problem" "Can't find script engine Python for script I did some googling and have also downloaded and installed the

Why can't I find any pywin32 documentation/resources

风流意气都作罢 提交于 2019-12-29 10:21:55
问题 I cannot find pywin32 documentation or even a little synopsis of what the module is (I am aware its for win32 API stuff). Is there any pywin32 documentation or resources? Maybe some examples? 回答1: The PyWin32 installation includes a .chm help file at [Pythonpath]\Lib\site-packages\PyWin32.chm . The same info is online at http://timgolden.me.uk/pywin32-docs/index.html And as P2bM states, you can also look at ActiveState's PyWin32 documentation, including a list of modules and a list of objects

Python - How to get the start/base address of a process?

不打扰是莪最后的温柔 提交于 2019-12-29 07:35:17
问题 How do I get the start/base address of a process? Per example Solitaire.exe (solitaire.exe+BAFA8) #-*- coding: utf-8 -*- import ctypes, win32ui, win32process PROCESS_ALL_ACCESS = 0x1F0FFF HWND = win32ui.FindWindow(None,u"Solitär").GetSafeHwnd() PID = win32process.GetWindowThreadProcessId(HWND)[1] PROCESS = ctypes.windll.kernel32.OpenProcess(PROCESS_ALL_ACCESS,False,PID) print PID, HWND,PROCESS I would like to calculate a memory address and for this way I need the base address of solitaire.exe

Associating my Windows computer to a wifi AP with Python

不羁的心 提交于 2019-12-29 06:57:19
问题 I'm trying to write a python script that can make my computer associate to a wireless access point, given the name as a string. For example, I might specify I want to connect to linksys , and my script would cause the computer to do that. I looked at this question, but wasn't able to understand what to do from looking at the links provided. Can somebody point me in the right direction? 回答1: I decided to take Paulo's suggestion and try using Powershell/the command line. I found an article

How can I use SetJob in win32print?

心不动则不痛 提交于 2019-12-25 05:19:56
问题 I want to clear or delete print jobs using Python. But how can I get JobID ? win32print.SetJob(hPrinter, JobID , Level , JobInfo , Command) How could I run this code? jobs = [] for p in win32print.EnumPrinters(win32print.PRINTER_ENUM_LOCAL,None, 1): flags, desc, name, comment = p pHandle = win32print.OpenPrinter(name) print = list(win32print.EnumJobs(pHandle, 0, -1, 1)) jobs.extend(print) SetJob(pHandle, id, 1,JOB_CONTROL_DELETE) #where should i get id from? win32print.ClosePrinter(pHandle)

Python: Export Messages as .msg using pywin32.client

可紊 提交于 2019-12-25 04:13:55
问题 I am hitting a road block with exporting outlook messages as .msg files. I'm not sure on how to accomplish this task. I have a program that currently reads the email and exports the attachments and once it completes it moves the message to a processed folder so I can keep track of what has been completed. I need to add a function that exports the entire email itself to a folder on the local machine. Has anyone accomplished this using pywin32.client? Here is the program as it stands now.