pywin32

Make a window transparent using Win32?

扶醉桌前 提交于 2019-11-28 10:27:02
Using Python Win32 extensions, how do you make an arbitrary window on Windows XP transparent? PabloG 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 ) | win32con.WS_EX_LAYERED ) winxpgui.SetLayeredWindowAttributes(hwnd, win32api.RGB(0,0,0), 180, win32con

Need skeleton code to call Excel VBA from PythonWin

╄→尐↘猪︶ㄣ 提交于 2019-11-28 09:33:49
I need to invoke a VBA macro within an Excel workbook from a python script. Someone else has provided the Excel workbook with the macro. The macro grabs updated values from an external database, and performs some fairly complex massaging of the data. I need the results from this massaging, and I don't really want to duplicate this in my Python script, if I can avoid it. So, it would be great if I could just invoke the macro from my script, and grab the massaged results. Everything I know about COM I learned from "Python Programming on Win32". Good book, but not enough for my task at hand. I

win32com.client.Dispatch works but not win32com.client.gencache.EnsureDispatch

倾然丶 夕夏残阳落幕 提交于 2019-11-28 08:40:47
问题 i'm learning win32com for python and I've got a strange problem. I'e trying to export Outlook Contacts in a List of Dictionnary. My code works perfectly with win32com.client.Dispatch("Outlook.Application). But it returns 0 contacts with win32com.client.gencache.EnsureDispatch("Outlook.Application) that is supposed to be faster and "safer". Here's my code : class MapiImport(): def __init__(self): self.olApp = win32com.client.Dispatch("Outlook.Application") self.namespace = self.olApp

How to retrieve the selected text from the active window

馋奶兔 提交于 2019-11-28 06:33:13
I am trying to create a simple open source utility for windows using Python that can perform user-defined actions on the selected text of the currently active window. The utility should be activated using a pre-defined keyboard shortcut. Usage is partially outlined in the following example: The user selects some text using the mouse or the keyboard (in any application window) The user presses a pre-defined keyboard shortcut The selected text is retrieved by our utility or copied to clipboard (both approaches should be fine) The keyboard shortcut-dependent action is performed on the selected

Can't start Windows service written in Python (win32serviceutil)

狂风中的少年 提交于 2019-11-28 05:28:36
I'm trying to start a simple service example: someservice.py: import win32serviceutil import win32service import win32event class SmallestPythonService(win32serviceutil.ServiceFramework): _svc_name_ = "SmallestPythonService" _svc_display_name_ = "display service" def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) def SvcStop(self): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) win32event.SetEvent(self.hWaitStop) def SvcDoRun(self): win32event.WaitForSingleObject(self.hWaitStop, win32event

Windows explorer context menus with sub-menus using pywin32

穿精又带淫゛_ 提交于 2019-11-28 04:34:55
I'm trying add some shell extensions using python with icons and a sub menu but I'm struggling to get much further than the demo in pywin32. I can't seem to come up with anything by searching google, either. I believe I need to register a com server to be able to change the options in submenu depending on where the right clicked file/folder is and the type of file etc. # A sample context menu handler. # Adds a 'Hello from Python' menu entry to .py files. When clicked, a # simple message box is displayed. # # To demostrate: # * Execute this script to register the context menu. # * Open Windows

Multiple django sites on Apache / Windows / mod_wsgi - problem with win32

核能气质少年 提交于 2019-11-28 03:43:40
问题 I have two django sites that use the same database and share some of the code. The main parent site is an extranet for staff and contractors, while the second site exposes some of the data to a few of our partners. I have managed to set up sites to work but found that if I launched Apache and went into the main site, then the partner site wouldn't work, returning an "Internal Server Error". If I restarted and went into the partner site, then the main site wouldn't work. So I guess they are

Connect to Exchange mailbox with Python [closed]

冷暖自知 提交于 2019-11-28 03:36:11
I need to connect to an Exchange mailbox in a Python script, without using any profile setup on the local machine (including using Outlook). If I use win32com to create a MAPI.Session I could logon (with the Logon() method) with an existing profile, but I want to just provide a username & password. Is this possible? If so, could someone provide example code? I would prefer if it only used the standard library and the pywin32 package. Unfortunately, enabling IMAP access for the Exchange server (and then using imaplib) is not possible. In case it is necessary: all the script will be doing is

Keyboard event not sent to window with pywin32

寵の児 提交于 2019-11-28 01:52:36
问题 I've wrote A code that gets the HWND from any program I want. So thats how I got the hwnd if your asking. The following code should bring up device manger and send the down arrow to the program. But it doenst. It does bring up the device manager but it doesnt send the arrow down key to the program, at least nothing happens. If I change the hwndMain number with the hwnd code of a notepad window, the code does work and sends the arrow down key import win32api import win32con import win32gui

Setting a cell's fill RGB color with pywin32 in excel?

梦想的初衷 提交于 2019-11-28 01:48:16
问题 I'm avoiding using any other set of modules. What I am trying to do is set a cell's color in Excel, using the pywin32 libary. So far I've found how to get the cells color: print xl.ActiveSheet.Cells(row, column).interior.color and you can set it simply by assigning it in a similar fashion: xl.ActiveSheet.Cells(row, column).interior.color = 0 #black My question is how to set the cell's colour in RGB? I need something called a ColorTranslator to OLE , but I don't know how to access system