pywin32

Python - Get Path of Selected File in Current Windows Explorer

假如想象 提交于 2019-11-30 17:46:48
问题 I am trying to do this in Python 2.7. I have found an answer for it in C# here, but I am having trouble recreating it in Python. The answer suggested here does explain the concept which I understand, but I have no idea how to get it going. Basically I just want to mark a file, press Winkey+C and have its path copied. I know how to do the hotkey part (pyhk, win32 [RegisterHotKey]), but my trouble is working around with the filepath. Thanks in advance! 回答1: it takes a lot of hacking around, but

Get list of open windows in Python

て烟熏妆下的殇ゞ 提交于 2019-11-30 16:26:48
I am writing an app in Python that must be able to send keys or text to another app. For example, if I have Firefox open, I should be able to send it an URL to open it. I already have the SendKeys module, and I have read about the win32 module too, but I do not know if there is a way to filter out process without open windows. Peter Hansen Usually, for this sort of "GUI automation" pyWinAuto is a good way to go. We use it to allow automated testing of GUI applications, and it ought to let you "type" URLs into Firefox (not to mention finding its window) as well. try using dragonfly . It has a

Receiving WM_COPYDATA in Python

痞子三分冷 提交于 2019-11-30 15:55:20
问题 I am trying to read from Python the WM_COPYDATA message some applications (I'm trying with Spotify) send to WindowsLiveMessenger to update the "What I'm listening to..." phrase. From what I have been able to find, WM_COPYDATA messages come in a COPYDATASTRUCT with the following structure: dwData in our case 0x547 so that it access the listening now feature cbData with the length of the string received lpData with a pointer to the string itself, may include Unicode characters The string should

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

≯℡__Kan透↙ 提交于 2019-11-30 15:07:22
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 posting the question I thought that by 'interacting with a dialog box' will implicitly mean that it is

How do you install pywin32 from a binary file in tox on Windows?

泪湿孤枕 提交于 2019-11-30 14:56:09
My application depends on pywin32 which I have installed in my system environment via Windows binary file. How do you install a module like pywin32 from a binary file in tox on Windows? There is now a version of pywin32 on PyPI that can be installed with pip. It is called pypiwin32 , and it installs the package using the binary wheel format. https://pypi.python.org/pypi/pypiwin32 pip install pypiwin32 Or, in tox.ini [testenv] deps = pypiwin32 来源: https://stackoverflow.com/questions/26639947/how-do-you-install-pywin32-from-a-binary-file-in-tox-on-windows

Using PythonService.exe to host python service while using virtualenv

不问归期 提交于 2019-11-30 13:10:19
I've got a Windows 7 environment where I need to develop a Python Windows Service using Python 3.4. I'm using pywin32's win32service module to setup the service and most of the hooks seem to be working ok. The problem is when I attempt to run the service from source code (using python service.py install followed by python service.py start ). This uses PythonService.exe to host service.py - but I'm using a venv virtual environment and the script can't find it's modules (error message discovered with python service.py debug ). Pywin32 is installed in the virtualenv and in looking at the source

Use Python to Write VBA Script?

我们两清 提交于 2019-11-30 09:51:39
This might be a bit of a stretch, but is there a possibility that a python script can be used to create VBA in MS Excel (or any other MS Office product that uses VBA) using pythonwin or any other module. Where this idea came from was pythons openpyxl modules inability to do column autowidth. The script I have creates a workbook in memory and eventually saves it to disc. There are quite a few sheets and within each sheet, there are quite a few columns. I got to thinking....what if I just use python to import a VBA script (saved somewhere in notepad or something) into the VBA editor in excel and

Get memory usage of computer in Windows with Python

跟風遠走 提交于 2019-11-30 08:54:12
How can I tell what the computer's overall memory usage is from Python, running on Windows XP? You'll want to use the wmi module. Something like this: import wmi comp = wmi.WMI() for i in comp.Win32_ComputerSystem(): print i.TotalPhysicalMemory, "bytes of physical memory" for os in comp.Win32_OperatingSystem(): print os.FreePhysicalMemory, "bytes of available memory" Seth You can also just call GlobalMemoryStatusEx() (or any other kernel32 or user32 export) directly from python: import ctypes class MEMORYSTATUSEX(ctypes.Structure): _fields_ = [ ("dwLength", ctypes.c_ulong), ("dwMemoryLoad",

os.path.islink on windows with python

大兔子大兔子 提交于 2019-11-30 08:26:20
问题 On Windows 7 with Python 2.7 how can I detect if a path is a symbolic link? This does not work os.path.islink() , it says it returns false if false or not supported and the path I'm providing is definitely a symbolic link so I'm assuming it's not supported on windows? What can I do? 回答1: The root problem is that you're using too old a version of Python. If you want to stick to 2.x, you will not be able to take advantage of new features added after early 2010. One of those features is handling

“Not implemented” Exception when using pywin32 to control Adobe Acrobat

。_饼干妹妹 提交于 2019-11-30 06:56:32
I have written a script in python using pywin32 to save pdf files to text that up until recently was working fine. I use similar methods in Excel. The code is below: def __pdf2Txt(self, pdf, fileformat="com.adobe.acrobat.accesstext"): outputLoc = os.path.dirname(pdf) outputLoc = os.path.join(outputLoc, os.path.splitext(os.path.basename(pdf))[0] + '.txt') try: win32com.client.gencache.EnsureModule('{E64169B3-3592-47d2-816E-602C5C13F328}', 0, 1, 1) adobe = win32com.client.DispatchEx('AcroExch.App') pdDoc = win32com.client.DispatchEx('AcroExch.PDDoc') pdDoc.Open(pdf) jObject = pdDoc.GetJSObject()