pywin32

Is there a python package to interface with MS Cluster ?

I need to write a couple of python scripts to automate the installation of Microsoft Cluster Ressources. More specifically, I'll need to query MS Cluster to be able to get a list of ressources with their parameters. And I also need to be able to create resources and set their parameters. Is someone knows if there is a package/module....

How do you load an embedded icon from an exe file with PyWin32?

I have an exe file generated with py2exe. In the setup.py I specify an icon to be embedded in the exe: windows=[{'script': 'my_script.py','icon_resources': [(0, 'my_icon.ico')], ... I tried loading the icon using: hinst = win32api.GetModuleHandle(None) hicon = win32gui.LoadImage(hinst, 0, win32con.IMAGE_ICON, 0, 0, win32con.LR_DEFAUL...

Get other running processes window sizes in Python

This isn't as malicious as it sounds, I want to get the current size of their windows, not look at what is in them. The purpose is to figure out that if every other window is fullscreen then I should start up like that too. Or if all the other processes are only 800x600 despite there being a huge resolution then that is probably what t...

How do I watch a file for changes using Python?

I have a log file being written by another process which I want to watch for changes. Each time a change occurrs I'd like to read the new data in to do some processing on it. What's the best way to do this? I was hoping there'd be some sort of hook from the PyWin32 library. I've found the win32file.FindNextChangeNotification function bu...

How to check if OS is Vista in Python?

How, in the simplest possible way, distinguish between Windows XP and Windows Vista, using Python and pywin32 or wxPython? Essentially, I need a function that called will return True iff current OS is Vista: >>> isWindowsVista() True ...

How can I determine the display idle time from Python in Windows, Linux, and MacOS?

I would like to know how long it's been since the user last hit a key or moved the mouse - not just in my application, but on the whole "computer" (i.e. display), in order to guess whether they're still at the computer and able to observe notifications that pop up on the screen. I'd like to do this purely from (Py)GTK+, but I am amenabl...

getting pywin32 to work inside open office 2.4 built in python 2.3 interpreter

I need to update data to a mssql 2005 database so I have decided to use adodbapi, which is supposed to come built into the standard installation of python 2.1.1 and greater. It needs pywin32 to work correctly and the open office python 2.3 installation does not have pywin32 built into it. It also seems like this built int python install...

Creating a python win32 service

I am currently trying to create a win32 service using pywin32. My main point of reference has been this tutorial: http://code.activestate.com/recipes/551780/ What i don't understand is the initialization process, since the Daemon is never initialized directly by Daemon(), instead from my understanding its initialized by the following: ...

FileChooser to select a directory, not a file

My code processes all the files in a folder on a Windows box. I want to offer the user (who happens to also be me) the option to select the folder to be processed, using the standard File Chooser dialog. I am trying to use the GetOpenFileName function to make this happen. (I am actually calling it from Python via pywin32, but that shoul...

Connect to Exchange mailbox with Python

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 someo...

Why does Excel macro work in Excel but not when called from Python?

I have an Excel macro that deletes a sheet, copies another sheet and renames it to the same name of the deleted sheet. This works fine when run from Excel, but when I run it by calling the macro from Python I get the following error message: ' Run-time error '1004': Cannot rename a sheet to the same name as another sheet, a referenced o...

Need skeleton code to call Excel VBA from PythonWin

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 ...

Interpreting Excel Currency Values

I am using python to read a currency value from excel. The returned from the range.Value method is a tuple that I don't know how to parse. For example, the cell appears as $548,982, but in python the value is returned as (1, 1194857614). How can I get the numerical amount from excel or how can I convert this tuple value into the numeri...

Extracting data from MS Word

I am looking for a way to extract / scrape data from Word files into a database. Our corporate procedures have Minutes of Meetings with clients documented in MS Word files, mostly due to history and inertia. I want to be able to pull the action items from these meeting minutes into a database so that we can access them from a web-inter...

Is there a way to decode numerical COM error-codes in pywin32

Here is part of a stack-trace from a recent run of an unreliable application written in Python which controls another application written in Excel: pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2146788248), None) Obviously something has gone wrong ... but what?[1] These COM error codes seem to be...

Need help debugging python html generator

The program is supposed to take user input, turn it into html and pass it into the clipboard. Start the program with welcome_msg() If you enter 1 in the main menu, it takes you through building an anchor tag. You'll add the link text, the url, then the title. After you enter the title, I get the following errors: File "<pyshell#23>", ...

What will I lose or gain from switching database APIs? (from pywin32 and pysqlite to QSql)

I am writing a Python (2.5) GUI Application that does the following: Imports from Access to an Sqlite database Saves ui form settings to an Sqlite database Currently I am using pywin32 to read Access, and pysqlite2/dbapi2 to read/write Sqlite. However, certain Qt objects don't automatically cast to Python or Sqlite equivalents when...

Getting pywin32 excelAddin.py working on Excel 2007

I'm trying get pywin32 excelAddin.py demo script on winXP MS Office Excel 2007, python 2.5.4. Though the Com add-in registers itself succesfully and is displayed in "com add-ins" list in Excel, it does not work. Only error feedback i get is on the "Load behaviour" line in excel's "com add-ins" dialog, says "Not loaded. A runtime error ...

Is there any preferable way to get user/group information from an Active Directory domain in Python?

For a Django application that I'm working on, I wanted to allow group membership to be determined by Active Directory group. After a while of digging through the pywin32 documentation, I came up with this: >>> import win32net >>> win32net.NetUserGetGroups('domain_name.com', 'username') [(u'Domain Users', 7), ...] I spent a while goog...

Encoding of string returned by GetUserName()

How do I get the encoding that is used for the string returned by GetUserName from the win32 API? I'm using pywin32 and it returns an 8-bit string. On my German XP, this string is obviously encoded using Latin-1, but this might not be the case for other Windows installations. I could use GetUserNameW, but I would have to wrap that mysel...