See the question and my original answer on StackOverflow

It's not obvious why this WindowId concept exists, beyond the fact it's documented for top-level windows only where HWND are for all windows. Maybe for a (future?) cross platform target?

Anyway, currently the WindowId's Value is equal to the HWND's value, so it's pretty easy to compute one from another.

Another way is to use an undocumented function from AppSDK's Microsoft.Internal.FrameworkUdk.dll file. You can declare this in C# (don't know in F#):

[DllImport("Microsoft.Internal.FrameworkUdk.dll")]
private static extern int Windowing_GetWindowIdFromWindow(
    IntPtr hwnd,
    out WindowId windowId);

or to avoid linking to WindowId structure:

private static extern int Windowing_GetWindowIdFromWindow(
    IntPtr hwnd,
    out ulong windowId); // windowId = hwnd...

This dll is part of the AppSDK Runtime and always loaded in an WinU3I app. Maybe overkill...