WinRT Windows Foundation API

3.2.1 · active · verified Thu Apr 16

winrt-windows-foundation is a Python package that provides a projection of the core Windows Runtime (WinRT) Foundation APIs, enabling Python developers to interact with fundamental Windows features and UWP application components. As of version 3.2.1, it offers enhanced asyncio integration, support for the Python buffer protocol, and streamlined API access. Releases are frequent, often coinciding with updates to the Windows SDK and Windows App SDK.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create and interact with a basic WinRT Uri object from the Windows.Foundation namespace, showcasing property access and object comparison.

from winrt.windows.foundation import Uri

def main():
    # Create a WinRT Uri object
    url = Uri("https://www.microsoft.com/python")

    print(f"Original URI: {url.AbsoluteUri}")
    print(f"Scheme Name: {url.SchemeName}")
    print(f"Domain: {url.Domain}")
    print(f"Path: {url.Path}")

    # Demonstrate a simple comparison
    another_url = Uri("https://www.microsoft.com/python")
    if url == another_url:
        print("URIs are equal.")

if __name__ == "__main__":
    main()

view raw JSON →