pywin32

Send Email From Specific Outlook Account Via Python?

≡放荡痞女 提交于 2019-12-06 14:01:20
问题 I had some code that was written to email lab users whenever certain processes had finished running. This was sent from a gmail account, using SMTP. However, my supervisor wants the mail to be sent from an official department address, which means that I have use Outlook and MAPI. I've had an account created which I want the email to originate from regardless of the lab machine the job is being run on. The problem is that I can only get email to send from the local Outlook account, and not all

Ask for admin access for a Python function in Windows

a 夏天 提交于 2019-12-06 11:34:23
I want to copy a list of files to the Windows system directory (C:\Windows) using a Python function. I have a function: import shutil def copy_list(src_list, dst): for file in src_list: shutil.copy(file, dst) And I want to call it like this: def copy_as_admin(): #... some code to obtain user elevation ... copy_list(files_list, "C:\\Windows\") How can I achieve this? PS: I'm using Python3, I tried solutions in this thread, How to run python script with elevated privilege on windows but those solutions are for Python version 2. The following example builds on Cyrbil's excellent work. In

How can I debug SendKeysCtypes on (win7 64bit, py2.7) further?

旧巷老猫 提交于 2019-12-06 09:41:53
Im trying to get SendKeysCtypes working on py2.7 and win7 64bit . Here is src Problem: Run SendKeysCtypes.py and nothing happens. Tests should open notepad and write some text. The problem code is this: def GetInput(self): "Build the INPUT structure for the action" actions = 1 # if both up and down if self.up and self.down: actions = 2 inputs = (INPUT * actions)() vk, scan, flags = self._get_key_info() for inp in inputs: inp.type = INPUT_KEYBOARD inp._.ki.wVk = vk inp._.ki.wScan = scan inp._.ki.dwFlags |= flags # if we are releasing - then let it up if self.up: inputs[-1]._.ki.dwFlags |=

Python library to open existing .xlsx workbook with charts [closed]

放肆的年华 提交于 2019-12-06 09:17:14
Closed. This question is off-topic . It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . I have to read a certain .xlsx file (file1.xlsx), pull data from another .csv files (file2.csv) and write the processed data into the original file (file1.xlsx) along with some charts. The file has existing charts, I have looked into openpyxl, xlswriter, xlsread, and other python libraries. It seems openpyxl is the only library which allows you to read and write files back with the same library. Others like

PyWin32 (226) and virtual environments

懵懂的女人 提交于 2019-12-06 06:32:58
[PyPI]: pywin32 226 has been released on 20191110 . It works on most of the Python installations ( e.g. works on the official versions downloaded from Python ), but not on virtual environments ( e.g. created with VirtualEnv ( v16.7.7 ), and (based on further research) Python 's venv ). I used Python v3.8 .0 and v3.7 .3 as lab rats. Here's the output for the former: [cfati@CFATI-5510-0:e:\Work\Dev\StackOverflow\q058805040]> "e:\Work\Dev\VEnvs\py_064_03.08.00_test0\Scripts\python.exe" -c "import win32api" Fatal Python error: init_import_size: Failed to import the site module Python runtime state

How does files get copy/cut/paste using clipboard operations (ctrl-c /ctrl-v)

℡╲_俬逩灬. 提交于 2019-12-06 06:05:45
Was trying to use win32clipboard to do the copy paste operations for text (till now), and was able to do it with ease.But now am wondering how does the copy/paste operations would be accomplished for folders/files etc through that. I am using python to achieve the same. Could not also find any relevant formats for that. Is it something like file path gets copied and then paste operation identifies clipboard data as file path and then actually does the file copy? No clue :(. beer_monk Windows copy/paste stores things as OLE objects ( http://en.wikipedia.org/wiki/Object_Linking_and_Embedding )

Heavily confused by win32api + COM and an answer from SO

风格不统一 提交于 2019-12-06 05:41:40
From my other question here on SO, I asked how to retrieve the current playing song from Windows Media Player and Zune, I got an answer from a c++ dev who gave me an explanation of how I would do this for WMP. However, I am no C++ dev, nor am I very experienced with the pywin32 library. And on-top of all that, the documentation on all this (especially concerning WMP) is horrible . Therefor, I need your help understanding how I would do the following in Python. Source I have working code in C++ to print the name of media currently playing in WMP. It's a simple console application (78 lines of

python: convert pywintyptes.datetime to datetime.datetime

左心房为你撑大大i 提交于 2019-12-05 14:50:56
I am using pywin32 to read/write to an Excel file. I have some dates in Excel, stored in format yyyy-mm-dd hh:mm:ss. I would like to import those into Python as datetime.datetime objects. Here is the line of code I started with: prior_datetime = datetime.strptime(excel_ws.Cells(2, 4).Value, '%Y-%m-%d %H:%M:%S') That didn't work. I got the error: strptime() argument 1 must be str, not pywintypes.datetime I tried casting it to a string, like so: prior_datetime = datetime.strptime(str(excel_ws.Cells(2, 4).Value), '%Y-%m-%d %H:%M:%S') That didn't work either. I got the error: ValueError:

pywintypes27.dll not found using Apache, Django, pywin32, Python2.7 and mod_wsgi

半世苍凉 提交于 2019-12-05 14:21:56
I have a Django application using django-mssql to communicate w/ SQL Server. This works just fine in the dev server (runserver) but under Apache/mod-wsgi, I get a error related to it trying to find a .dll which does exist: Exception Type: ImportError Exception Value: No system module 'pywintypes' (pywintypes27.dll) Exception Location: C:\Python27\lib\site-packages\win32\lib\pywintypes.py in __import_pywin32_system_module__, line 98 Python Executable: C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin\httpd.exe I used ActivePython2.7.2, mod_wsgi, pywin32 Build 216 and Django1.3.1,

What's making this security descriptor go bad?

房东的猫 提交于 2019-12-05 10:52:03
I'm trying to read the access for files and directories in Windows using this code (patterned after Tim Golden's proposed patch to os.access to make it read from ACLs on Windows ): from ctypes import( windll, wintypes, c_char_p, c_void_p, byref ) from win32api import GetCurrentThread from win32security import ( GetFileSecurity, DACL_SECURITY_INFORMATION, ImpersonateSelf, SecurityImpersonation, OpenThreadToken, TOKEN_ALL_ACCESS, MapGenericMask ) from ntsecuritycon import ( FILE_READ_DATA, FILE_WRITE_DATA, FILE_EXECUTE, FILE_ALL_ACCESS ) import pywintypes import winnt TRUE = 1 def CheckAccess