[Python] How to get the app name from `app_user_model_id` in Python using winsdk / WinRT?

Discussão em 'Python' iniciado por Stack, Junho 18, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using the winsdk Python package (WinRT bindings) to access media sessions via GlobalSystemMediaTransportControlsSessionManager.

    I can successfully get the list of active sessions and their source_app_user_model_id using:

    from winsdk.windows.media.control import GlobalSystemMediaTransportControlsSessionManager as MediaManager

    manager = await MediaManager.request_async()
    for session in manager.get_sessions():
    print(session.source_app_user_model_id)


    For example, I get values like:

    Chrome.AI6Y5TE6AH3DDYXV66D2XOWVLA
    308046B0AF4A39CB


    (The second is Firefox id lol)


    I want to resolve these IDs to user-friendly app names (like "Google Chrome" or "Firefox").

    In C++/WinRT, I found this solution using AppInfo::GetFromAppUserModelId:

    from winsdk.windows.applicationmodel import AppInfo

    def get_display_name(app_id):
    return AppInfo.get_from_app_user_model_id(app_id)


    But it throws:

    OSError: [WinError -2147023728] Element not found


    I assume this happens for non-UWP apps.


    I also tried using the Windows.Management.Deployment.PackageManager to enumerate installed packages and get their display names:

    from winsdk.windows.management.deployment import PackageManager
    pm = PackageManager()
    for package in pm.find_packages_for_user(""):
    print(package.display_name)


    However, this only returns a list of system or default apps available for new user accounts (like Microsoft Edge, Photos, etc.). It does not include apps like Chrome or Firefox.

    How can I get the application display name from source_app_user_model_id using Python and winsdk / WinRT? Is there any fallback method for non-UWP apps (e.g. Firefox, Chrome)?

    Continue reading...

Compartilhe esta Página