I try to export one of my xlsx files as PDF with pywin32: Unfortunately I get this com_error: In the end I want to do use this conversion on 30 xlsx files at once. I know how to write the loop for this but can not fix the above mentioned error. Answer When using Python paths on Windows, you need
Tag: pywin32
Python: how to get Windows desktop background color
Context: on my office PC there is apllied corporate policy -> standard company picture on desktop wallpaper. Picture is too bright; I switch it off to more dark backgroubd color, do it by manually running the script several times per day. Aim: automate this operation with Python once per some time check some desktop background pixel if it color is
How to change username of job in print queue using python & win32print
I am trying to change the user of a print job in the queue, as I want to create it on a service account but send the job to another users follow-me printing queue. I’m using the win32 module in python. Here is an example of my code: The problem is I get an error at the win32print.SetJob() line. If
time.sleep does not work for multithreaded
I was trying to multithread the code for “Suspend / Hibernate pc with python” provided by Ronan Paixão when I find that time.sleep() does not suspend the thread that run pywin32 module. >>> Warning! The following code will put Windows to sleep <<< The print function did waited for time.sleep(), but the Windows was immediately put to sleep. What happened?
pywintypes.com_error: (-2147221008, ‘CoInitialize has not been called.’, None, None)
When I try to run this code as is I get this error “IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) pywintypes.com_error: (-2147221008, ‘CoInitialize has not been called.’, None, None)” , however if I run stp_tracker alone it works fine and if I run notify stp’s alone it works just fine. I appreciate anyones input. Thanks Answer Apologize for that, but searching
How to mute/unmute sound using pywin32?
My searches lead me to the Pywin32 which should be able to mute/unmute the sound and detect its state (on Windows 10, using Python 3+). I found a way using an AutoHotkey script, but I’m looking for a pythonic way. More specifically, I’m not interested in playing with the Windows GUI. Pywin32 works using a Windows DLL. so far, I
How can I use SetJob in win32print?
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? Answer Starting from your code, I’ve managed to create a small script that deletes any print job on any (local) printer (I’ve tested it and it works). Here it is
How can I get a list of removable drives plugged in the computer?
I would like to get a list of the removable drivers that are plugged in to the computer. I think it can be done by using some registry, but I don’t know how exactly. If there is another way I would like to hear about it. Note: It’s important that I will be able to separate the removable drives from
Get Printer Status Code with win32print
I have read the documentation of win32print which indicates that GetPrinter is the method which is used to obtain the status of the printer. However, this method returns a complete tuple of data and I’m at a loss at to which element indicates the actual status. Any ideas? Answer If you pass Level=2 into GetPrinter it should return a dict.