Automating Windows Applications with win32com
Presenter
Roy H. Han
Summary
With Mark Hammond's pywin32 extensions, any windows application with a COM interface becomes a tool that you can use with Python.
Step by step, you will learn how to do the following using Python.
- Extract mail from Microsoft Outlook and Lotus Notes.
- Create formatted Microsoft Excel spreadsheets from databases.
- Update databases from Excel spreadsheets or Access files.
- Create a mail client that responds to queries through Microsoft Outlook and Lotus Notes.
- Create a mail client that updates databases through Microsoft Outlook and Lotus Notes.
- Clip images from shapefiles using ArcGIS.
- Call using Skype.
You will also learn how to do the following using Python.
- Handle events in Microsoft Office.
- Write toolbar add-ins for Microsoft Office.
- Bypass the Outlook security dialog box.
Intended Audience
Intermediate Python developers
Requirements
- Windows XP or higher
- Python 2.5 or higher
- Mark Hammond's pywin32 extensions ( http://sourceforge.net/projects/pywin32 )
- Microsoft Office 2000 or higher
- (Optional) Lotus Notes, Matlab, ArcGIS, Access, PowerPoint, Vim
- (Optional) wxPython, wxGlade
Slide Outline
Automating Windows Applications with win32com
- Next thirty minutes: Intro
- Why access existing applications through Python?
- Make your computer do it
- Icebreaker: Your expectations
- Setup your computer
- Which applications can we access through Python?
- What do we need to automate an application?
- How do I know if my target application has a COM interface?
- Which applications can we access through COM?
- Get a partial list of ProgIDs using WBEM
- Cycle through the registry and try to dispatch each ProgID
- ProgIDs for some applications
- How do we know what methods and attributes are available?
- Review: What do we need to automate an application?
- Mini Projects Tutorial Format
- Basics Mail Events Add-Ins More
- Next thirty minutes: Basics
- Make an Excel spreadsheet from a database
- Update a database using an Excel spreadsheet
- Make a Word document from a database
- Run Python commands from Vim
- Run Python commands from Vim with wxPython & wxGlade
- Get contacts from Outlook
- Explore handles
- Explore dialog boxes
- Interact with dialog boxes
- Bypass the Outlook security dialog box
- Catching COM errors
- Next thirty minutes: Mail
- Update a database using Outlook
- Reply to email with Outlook
- Reply to email with Lotus Notes
- Next thirty minutes: Events
- Make a toolbar button in Excel
- Debugging using win32traceutil
- Update database from an Excel spreadsheet in real-time
- Run Python commands from an Excel spreadsheet
- Next ten minutes: Add-ins
- How to write an add-in
- Find a CLSID for your add-in
- Cut and paste the add-in class definition
- Define the behavior for your add-in by overriding methods in the class definition
- Register your add-in
- Write an add-in for Excel
- Getting a CLSID for your add-in
- Write an add-in for Word Write an add-in for Outlook
- Next thirty minutes: More
- Speak using SpVoice
- Call using Skype
- Convert a document to PDF
- Do calculations in Matlab
- Clip images from shapefiles using ArcGIS
- Extract data from an Access database
- Move your mouse
- Click (Simple)
- Type (Simple)
- Click and Type (Complex)
Reference: win32com
Reference: Microsoft Excel
Reference: Lotus Notes
Reference: Microsoft Outlook
Reference: Databases and dates
Acknowledgments
Contact
Presenter Biography
Roy lives with his girlfriend in New York and is a Masters student in Machine Learning at Columbia University. He works at the Technology Commercialization Office of the City University of New York, helping professors patent their inventions and license them to companies. He is also using clustering and convolutional neural networks to locate rural households in satellite data for the Millennium Villages project of the Earth Institute. Before graduate school, Roy went to Stuyvesant High School and majored in mathematics and neuroscience at New York University.
Notes
March 24, 2008 The updated slides answer the following questions:
- How can I detect when a certain dialog pops up using Python?
- How can I click the OK button in a dialog box using Python?
- How can I bypass the Outlook security dialog box using Python?
- How can I simulate mouse clicks and keyboard input using Python?
Contact
starsareblueandfaraway [at] gmail.com
























.