The pywin32 package provides access to various Windows APIs within Python. These APIs can be used to create UI objects (windows, dialogs, etc..), interface to native or 3rd party libraries using COM, access low-level OS functionality, and much more.
Installation:
Once pywin32 is installed, you can browse the installation folder for documentation and sample scripts. The pywin32 package provides a wealth of functionality that cannot be completely covered by this article.
Here is a very short example of opening up Excel:
import win32com.client as win32
excel = win32.gencache.EnsureDispatch('Excel.Application')
excel.visible = True
_ = input("Press ENTER to quit:")
excel.Application.quit()
Once you run this from the command line, you should see Excel open up. When you press ENTER, the application will close.
Comments