pywin32

ImportError: DLL load failed when importing win32clipboard in application frozen with cx_Freeze

安稳与你 提交于 2019-12-19 09:26:56
问题 I've got a Python 2.7 program that imports win32clipboard . I tried to freeze it with cx_Freeze 4.2.3 on Windows XP SP3 32-bit, to create an installation MSI. I made a setup.py according to the cx_Freeze documentation, and used the following command: c:\python27\python.exe setup.py bdist_msi When I run it on another PC that doesn't have Python 2.7 installed, I get an exception on the line that imports win32clipboard : ImportError: DLL load failed: The specified module could not be found. I

Python Windows File Copy with Wildcard Support

心已入冬 提交于 2019-12-19 05:56:20
问题 I've been doing this all the time: result = subprocess.call(['copy', '123*.xml', 'out_folder\\.', '/y']) if result == 0: do_something() else: do_something_else() Until today I started to look into pywin32 modules, then I saw functions like win32file.CopyFiles(), but then I found it may not support copying files to a directory. Maybe this functionality is hidden somewhere, but I haven't found it yet. I've also tried "glob" and "shutil" combination, but "glob" is incredibly slow if there are

How to check all emails that came in within a time period?

流过昼夜 提交于 2019-12-19 03:58:05
问题 I have the following method get_email() that basically every 20 seconds, gets the latest email and performs a series of other methods on it. def get_email(): import win32com.client import os import time import datetime as dt date_time = time.strftime('%m-%d-%Y') outlook = win32com.client.Dispatch("Outlook.Application").GetNameSpace("MAPI") inbox = outlook.GetDefaultFolder(6) messages = inbox.Items message = messages.GetFirst() # any time calling GetFirst(), you can get GetNext().... email

Get list of open windows in Python

跟風遠走 提交于 2019-12-18 18:05:34
问题 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. 回答1: 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"

Portable Python com server using pywin32

孤人 提交于 2019-12-18 13:02:21
问题 Is it possible to run comserver without requiring elevation. For example I am able to run code from Python.TestServer (below) but it requires elevation. Python.TestServer code is at: Consuming Python COM Server from .NET Is it possible to run com server which doesn't require elevation so that I can run com object without having Administrative password. for example import pythoncom from win32com.server import localserver class demoObj(object): _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER _reg

SMTP through Exchange using Integrated Windows Authentication (NTLM) using Python

风格不统一 提交于 2019-12-18 10:55:21
问题 I want to use the credentials of the logged-in Windows user to authenticate an SMTP connection to an Exchange server using NTLM. I'm aware of the python-ntlm module and the two patches that enable NTLM authentication for SMTP, however I want to use the current user's security token and not have to supply a username and password. Very similar problem to Windows Authentication with Python and urllib2. 回答1: Although the solution below only uses the Python Win32 extensions (the sspi example code

Can't close Excel completely using win32com on Python

本秂侑毒 提交于 2019-12-18 10:35:48
问题 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 = excel.Workbooks wbs.Close() excel.Quit() wbs = None excel = None # <-- Excel Closes here But when I do the following, it does not close. excel = DispatchEx('Excel.Application') wbs = excel.Workbooks wb = wbs.Open('D:\\Xaguar\\A1.xlsm') wb.Close(False) wbs.Close() excel.Quit() wb = None

Make a window transparent using Win32?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 19:24:18
问题 Using Python Win32 extensions, how do you make an arbitrary window on Windows XP transparent? 回答1: SetLayeredWindowsAttributes example: import win32gui import win32con import winxpgui import win32api import subprocess import time subprocess.Popen("notepad.exe", shell=True) time.sleep(1) hwnd = win32gui.FindWindow(None, "New file - metapad") ## The caption of my empty notepad (MetaPad) win32gui.SetWindowLong (hwnd, win32con.GWL_EXSTYLE, win32gui.GetWindowLong (hwnd, win32con.GWL_EXSTYLE ) |

Getting Battery Capacity Windows with Python

北慕城南 提交于 2019-12-17 18:59:36
问题 I am looking to figure out both the current Battery Capacity and the Design Capacity. So far what I could get to work is using the Win32_Battery() class which doesn't give all the information I need (at least not on my system). I used the pure-python wmi library for that. On the other hand I found this which works In Python, how can I detect whether the computer is on battery power?, but unfortunately it doesn't provide any information on Capacity neither. The Battery Information structure

GetWindowRect too small on Windows 7

爷,独闯天下 提交于 2019-12-17 06:14:17
问题 The actual problem I'm trying to solve is, I want to automatically find out the size of the margins around windows. If you can find a better way, please by all means answer that instead of this. To do this I decided to take a screenshot of a test window and measure the margins. This is simple enough, as I expect no margins will ever be bright pink, but I admit it's a hack. I use GetWindowRect (py) to get the bounding box, and PIL to grab a screenshot and crop to the bounding box. The problem