Questions tagged [pywin32]

The PyWin32 package is a close wrapper around Microsoft Windows API. It was created and is still maintained by Mark Hammond.

Python for Windows Extension (PyWin32) is a close wrapper around Microsoft Windows API. It is so close that you can actually read MSDN documentation and almost directly translate their examples into Python. PyWin32 is actively developed and is supported in Python 2.x and 3.x.

Latest official build can be downloaded here: https://sourceforge.net/projects/pywin32/files/pywin32/

You can get support by joining their mailing list here: http://mail.python.org/mailman/listinfo/python-win32. ActiveState maintains a good copy of PyWin32's documentation: http://docs.activestate.com/activepython/2.7/pywin32/win32_modules.html

Tim Golden has written several add-on packages for this project, such as WMI, winshell and WinSys. These may be browsed here: http://timgolden.me.uk/python/ He also has many tutorials on his website for PyWin32 and his own packages that are well worth the time to learn.

1996 questions
410
votes
28 answers

How do I watch a file for changes?

I have a log file being written by another process which I want to watch for changes. Each time a change occurs I'd like to read the new data in to do some processing on it. What's the best way to do this? I was hoping there'd be some sort of hook…
Jon Cage
  • 36,366
  • 38
  • 137
  • 215
159
votes
16 answers

ImportError: no module named win32api

I am using Python 2.7 and I want to use pywin32-214 on Windows 7. I installed pywin32-214 by using the MSI installer. But when I import win32api in my Python script, it throws the error: no module named win32api What should I do? How can I use…
akshay
  • 1,641
  • 2
  • 11
  • 7
79
votes
32 answers

How to fix "ImportError: DLL load failed" while importing win32api

I'm setting up an autoclicker in Python 3.8 and I need win32api for GetAsyncKeyState but it always gives me this error: >>> import win32api Traceback (most recent call last): File "", line 1, in ImportError: DLL load failed while…
Glxce
  • 901
  • 1
  • 5
  • 5
77
votes
2 answers

Why can't I find any pywin32 documentation/resources

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?
in70x
  • 1,170
  • 1
  • 10
  • 16
56
votes
12 answers

import win32api error in Python 2.6

When running python26 under windows OS (64bits)..... I have got errors like: import win32api" error in Python 2.6: pywintypes26.dll or pythoncom26.dll missing ImportError: DLL load failed: The specified module could not be found. I have done the…
Vin.X
  • 4,759
  • 3
  • 28
  • 35
49
votes
5 answers

How to install pywin32 module in windows 7

I am trying to install pywin32. I downloaded it from sourceforge.net. When I run setup.py install it shows "Unable to find vcvarsall.bat". I Googled about it and found that I have to install MinGW and set path then run python setup.py build…
narayanpatra
  • 5,627
  • 13
  • 51
  • 60
44
votes
11 answers

Symlinks on windows?

Does anyone know of a way to make/read symbolic links across versions of win32 from Python? Ideally there should be a minimum amount of platform specific code, as I need my app to be cross platform.
Harkonnen Jama
39
votes
4 answers

What can you do with COM/ActiveX in Python?

I've read that it is possible to automate monthly reports in Crystal Reports with COM/ActiveX. I'm not that advanced to understand what this is or what you can even do with it. I also do a lot of work with Excel and it looks like you also use…
mandroid
  • 2,308
  • 5
  • 24
  • 37
36
votes
1 answer

Error "ValueError: can't format dates this early" on one PC, works on other

I have a Python script that works perfectly fine on my development PC. Both are Windows 7 with the same Python version (2.7.9). However on the target machine I get a ValueError: can't format dates this early The error seems to come from pywin32…
beginner_
  • 7,230
  • 18
  • 70
  • 127
30
votes
5 answers

Is there a way to decode numerical COM error-codes in pywin32

Here is part of a stack-trace from a recent run of an unreliable application written in Python which controls another application written in Excel: pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2146788248),…
Salim Fadhley
  • 22,020
  • 23
  • 75
  • 102
30
votes
8 answers

Can't close Excel completely using win32com on Python

This is my code, and I found many answers for VBA, .NET framework and is pretty strange. When I execute this, Excel closes. from win32com.client import DispatchEx excel = DispatchEx('Excel.Application') wbs =…
sacabuche
  • 2,781
  • 1
  • 27
  • 35
28
votes
4 answers

Connect to Exchange mailbox with Python

I need to connect to an Exchange mailbox in a Python script, without using any profile setup on the local machine (including using Outlook). If I use win32com to create a MAPI.Session I could logon (with the Logon() method) with an existing…
Tony Meyer
  • 10,079
  • 6
  • 41
  • 47
27
votes
1 answer

ctypes: construct pointer from arbitrary integer

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…
sebulba
  • 1,245
  • 2
  • 10
  • 17
26
votes
5 answers

How to check if OS is Vista in Python?

How, in the simplest possible way, distinguish between Windows XP and Windows Vista, using Python and pywin32 or wxPython? Essentially, I need a function that called will return True iff current OS is Vista: >>> isWindowsVista() True
Dzinx
  • 55,586
  • 10
  • 60
  • 78
25
votes
4 answers

python win32 extensions documentation

I'm new to both python and the python win32 extensions available at http://python.net/crew/skippy/win32/ but I can't find any documentation online or in the installation directories concerning what exactly the win32 extensions provide. Where is this…
Ben
1
2 3
99 100