Questions tagged [pywin32]
The PyWin32 package is a close wrapper around Microsoft Windows API. It was created and is still maintained by Mark Hammond.
2,016
questions
0
votes
0
answers
24
views
How to solve exception in Python when using COM port with win32?
I have a Python script which open and start measures in CANoe.
It already opens CANoe but I get the COM error:
Exception has occurred: com_error
(-2147352567, 'Exception occurred.', (0, None, None, ...
0
votes
0
answers
35
views
winpy32 throws -2146826246 when accessing a specific cell using WorkSheet.Range('A1').value
I have a script that is reading a complex model in excel, using pywin32. In the first part of the script, model inputs are found from the input worksheet within the workbook through InputWorkSheet....
0
votes
0
answers
21
views
How to convert docx (bytes stream) to pdf (bytes stream) with win32com.client?
I use win32com.client to convert DocX to PDF. I get DocX as a bytes stream and want not to save but get pdf as a bytes stream for further processing:
def convert_docx_to_pdf(docx_bytes_stream):
...
0
votes
0
answers
39
views
How do I create task which runs even when the user is logged out? (Pywin32 COM)
I am new to python COM objects and tried to write a script that creates a scheduled task using the PyWin32 wrapper. The below is what I tried:
I am getting an error that says task doesn't exist. When ...
0
votes
0
answers
21
views
How to access the derived objects from NavigationModule object (Outlook) using python?
I am trying to make a python 3 script that reads the calendar events of the user (from a subfolder of the 'All Group Calendars' folder), filters them, then outputs the filtered ics file. I had an ...
0
votes
0
answers
41
views
How to catch excel data refresh exception using python
I have a python script that refreshes an entire excel workbook.
Its a standard win32 code like this...
excel = win32.gencache.EnsureDispatch('Excel.Application')
wb = excel.Workbooks.Open(filepath)
...
1
vote
0
answers
22
views
How to resolve "PyInstaller cannot check for assembly dependencies" at runtime
I'm attempting to package a Python program with pyinstaller that loads python modules at runtime from a plugins subfolder. All works, except when packaged with pyinstaller.
I think I need to add a ...
0
votes
0
answers
20
views
SHGetFileInfoW not modifying reference passed into function
I'm trying to create my own version of a file explorer in python. I'm stuck trying to get a file's associated icon.
Currently I'm using the SHGetFileInfoW imported from the ctype library. Below is my ...
0
votes
1
answer
23
views
Sending Mail via outlook with pywin32
I have a quite "simple" Problem. I want to send an E-Mail with Python via opening the Local OutLook and sending it. This did work fine for a while and suddenly it stopped working. Since then ...
0
votes
0
answers
27
views
win32gui.EnumWindows starting with invalid window handle?
I have been using this piece of code I made for a few months now to check if a certain group of windows I have open are stuck on a certain window title for a given amount of seconds, and then closes ...
0
votes
2
answers
32
views
Accessing nested Inbox folders in Outlook with Python
I am trying to use Python to get attachments stored in an Outlook subfolder nested inside my Inbox.
Let's call the folder that I want to access "TargetFolder," and each sub-level "Sub ...
0
votes
0
answers
46
views
Python service error: The service process could not connect to the service controller
I created a Python app that uses FastAPI and fetches data from an SQL Server database in Visual studio code 2022.
And I want to create a windows service from this app.
Here is the code for the ...
1
vote
0
answers
44
views
How to slow down mouse speed when using win32api
I'm attempting to make my mouse slowly go across my screen but have had trouble finding a way to slow down the mouse speed. Someone posted a solution to an issue 11 months ago the solution they posted ...
0
votes
1
answer
57
views
How to Insert Block in AutoCAD using python
I am encountering a problem while trying to insert blocks in AutoCAD using the Pywin32 library and pyautocad. I've been working on a project that requires automating some tasks in AutoCAD 2024.
here ...
1
vote
0
answers
25
views
why Python win32api.GetCursorPos() compress coordinates 1.25 times
For a long time I could not understand why the coordinates that I receive from win32gui.GetCursorPos() and those that I send to the screenshot do not match, until I noticed that for some reason they ...
-1
votes
1
answer
70
views
Python ctypes long integer error, how can i fix this?
I am developing memory snapshot / acquisition software with Python, so I use the "pymem_snapshot" library and "winpmem" driver.
import ctypes
import struct
import sys
import ...
0
votes
1
answer
33
views
Single objective multiple integer variable optimisation of an Excel model - Python Pymoo library
I am trying to optimize a large Excel model using Pymoo, I have set up the problem to communicate with Excel via pyWin32.
During debugging in VSCode, I get the following exception:
Exception
('Problem ...
0
votes
0
answers
52
views
"The request is not supported" error (50) when using PeekNamedPipe from within a windows docker container
When creating a windows named pipe from a service running on a host windows machine and communicating with it from client application running within a windows docker container, The following error ...
0
votes
0
answers
46
views
Artifacts after corner rounding, pywin32
I have minimal code in python kivy + pywin32. I use the CreateRoundRectRgn function to create a region with rounded corners, and then assign this region to my window via SetWindowRgn. How to remove ...
0
votes
0
answers
15
views
How to capture chrome while it background or minimized with pywin32
It give only black screen.
Here is the code i tried:
def get_screenshot(self):
# get the window image data
wDC = win32gui.GetWindowDC(self.hwnd)
dcObj = win32ui.CreateDCFromHandle(wDC)
...
0
votes
0
answers
10
views
How do you call SetICMMode() for Color Management from python win32
I'm writing a Python program that uses win32ui, win32print, win32con, etc.
My RGB(0,128,0) which looks like a nice Green on the Display, but is Olive-Yellow on the printer,
when I print like this:
...
0
votes
1
answer
43
views
How get some columns from an excel sheets and save as pdf with client dispatch?
I have an excel file with six columns (Number, Name, Group, folio, adress and e-mail), i need to use client dispatch, to get only the columns (Name, Group and e-mai) of the sheet and save it as pdf in ...
0
votes
0
answers
135
views
pywin32 doesn't work on wine in docker container
My application runs in docker containers. I run Docker desktop for Windows. So I've insalled a wine image for python3 https://github.com/webcomics/pywine/tree/main, updating the dockerfile as follow:
...
2
votes
0
answers
85
views
Copy with SHFileOperation for files in non-drive-letter like Computer\Phone\card\DCIM\test.jpg
Context: I know that using SHFileOperation for copying with Windows Shell has been replaced by IFileOperation ("Copies, moves, renames, or deletes a file system object. This function has been ...
1
vote
1
answer
111
views
Copy file with Windows using Shell API CopyItem: "No such interface supported" for non-drive-letter paths like Computer\Phone\card\DCIM\test.jpg
I'm using Windows Shell API IFileOperation to copy files from a phone (connected on USB) to the PC. It would be impossible with usual file-based copy functions (os or shutil), because it has no driver ...
0
votes
2
answers
67
views
How to save an Excel file via COM interface in a github actions workflow
I've got a self-hosted windows runner and I try to run a workflow that executes a python script which creates an Excel file. The .yaml code of the workflow:
name: test
run-name: test
on: [push]
jobs:
...
1
vote
2
answers
1k
views
*win32ctypes.pywin32.pywintypes.error when using pyinstaller in VS Code - Possible Virus/Trojan?
I am using pyinstaller to generate an executable code for my python.py file. However, I am getting this error:
File "C:\Users\xxxxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\...
0
votes
0
answers
114
views
What message is sent when the mouse moves?
I read that mouse_event() has a MOUSEEVENTF_MOVE message.
When I send a MOUSEEVENTF_MOVE message, the cursor moves.
Similarly, when I try to drag and drop by sending the MOUSEEVENTF_LEFTDOWN, ...
0
votes
0
answers
104
views
What is the difference between "mouse_event" and "SendMessage"? [duplicate]
I have two functions that perform clicks using pywin32.
One that uses win32api.mouse_event:
def click_1(hwnd, x, y):
win_activate(hwnd)
win32api.SetCursorPos((x, y))
time.sleep(.1)
...
0
votes
0
answers
41
views
how to get a list of the open windows within an application
Trying to obtain a list of open window(s) but within an application.
Using the code below shows the top level windows and one of them is the application in question
names = []
def winEnumHandler(hwnd,...
0
votes
0
answers
101
views
BadZipFile error confusion with Python zipfile library
I wrote the functions below in an attempt to extract tabular data from emailed zip file attachments and dump the contents to a pandas data frame. I used temp files to try to be efficient with resource ...
0
votes
0
answers
37
views
Aspen Plus slow initializing
So I am optimizing Aspen Models via Python and using the win32 library to connect the 2 with each other. I was wondering wether there is a way to speed op the initialization as it takes pretty long (...
0
votes
0
answers
32
views
how can I use win32print to print a file without changing the default printer?
Good afternoon! I can't print a document if the printer is not installed by default on windows 10.
I tried to change the default printer before printing and return it back, but without result. It ...
0
votes
1
answer
101
views
Capturing a screenshot of a fullscreen game fails
This works on a normal window but in a fullscreen game this is returning a black screen so I changed the dtype = numpy.uint8 to dtype = numpy.uint16 and now I'm getting the this error. I think it has ...
0
votes
0
answers
10
views
Excluding hidden tabstops
I am trying to extract the tab stops of a paragraph and I am using win32 and this line of code to loop through each tabstops.
for tab in para_range.ParagraphFormat.TabStops:
But even there is no ...
0
votes
0
answers
56
views
Architecture dependent requirements with `poetry`
I am supporting a system which is main running Python 3.10 on Windows but has limited delivery on Linux. We use poetry to manage the package environment.
For NTLM authentication with requests, I ...
0
votes
0
answers
51
views
ImportError: DLL load failed while importing win32gui: The specified module could not be found
i am using win32gui libaray and the code runs in the Python environment without any problems but when I get the exe output with pyinstaller and execute it
Such an error will be displayed: ImportError: ...
0
votes
0
answers
19
views
How can I embed selenium browser inside of pyqy window
I want to embed selenium inside of pyqt5 application. I've tried to use win32gui to findwindow and move into the qt window. HOWEVER, it never works naturally and keyboard press does not work inside of ...
0
votes
0
answers
24
views
I have a kernal error that says,"ImportError: DLL load failed while importing win32api: The specified procedure could not be found"
This kernel error is not letting me run any of my notebooks on jupyter notebooks. I was trying to run scripting code using pyansys and it just gave me the kernel error
I tried pip instal pywin32 but i ...
0
votes
0
answers
27
views
how to read <class 'django.core.files.uploadedfile.InMemoryUploadedFile'> file using gencache.EnsureDispatch("Excel.Application")
I have been trying to read inmemory file using win32com.client named EnsureDispatch. but it gives error like this "pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft Excel'...
0
votes
0
answers
49
views
How to determin if an app is running in the foreground or background?
I'm using Python to launch AWCC.exe (Alienware Command Center) and the problem I'm having is when close AWCC it doesn't close. It gets removed from the desktop and stays running as a background ...
0
votes
0
answers
73
views
use python win32gui check a button,Is there any way to Judge before check
there is a check button on windows
use python win32gui.i can find the handle and check it using PostMessage.
here is code
bt=win32gui.FindWindowEx(hwnd,None,'Button','设置用户信息(&L)')
win32gui....
0
votes
0
answers
40
views
Passing pointer to ctypes.Structure
I am trying to figure out how to implement a function that waits for an event to be signaled.
The pointer is returned by a dll function which is a struct that stores 3 items. Two of them which are ...
0
votes
0
answers
16
views
Optimising code for processing .docx files
I've recently tried out learning Python. I'm currently trying to make a project that can be used for my work. Basically, it iterates through the whole .docx file and check if each paragraph does not ...
0
votes
0
answers
29
views
Sending Keys to an Application with Win32Api [duplicate]
I am trying to send keys to an application so I can have my player move around while I am gone. I took a look at the win32api and it's what I need, but for some reason, when I run my code, it does ...
1
vote
1
answer
80
views
Why is my Docx converter returning 'None'
I am new to web development and trying to create a language translation app in Django that translates uploaded documents. It relies on a series of interconversions between pdf and docx. When my code ...
0
votes
0
answers
87
views
PyWin32 issue after coverting pyhon script to exe using PyInstaller
I wrote a python script that collects Windows Events and it works fine when I run the script, however I'm using PyInstaller to covert my script to an exe. PyInstaller successfully coverts the script ...
0
votes
0
answers
132
views
Python Flask Application with waitress as an Windows Service
I am trying to get a Flask Application on a Windows Server running as a service. I want to use the pywin32 package and I get to the point, where the Windows Service gets installed, but when I try to ...
0
votes
0
answers
27
views
com_error at /translator/translator_upload/ (-2147221008, 'CoInitialize has not been called.', None, None)
I am new to web development and trying to create a language translation app in Django that translates uploaded documents. It relies on a series of interconversions between pdf and docx. When my code ...
0
votes
1
answer
52
views
In the document it puts all the paragraphs in format and size specific PYWIN32
In the word document all the paragraphs appear in format and size, I only want it to change the bold format and size in the paragraphs that have ## or ###. In the cmd I get this:
EXAMPLE MARKDOWN (...