The following sample has reliably returned the name of the process that is associated with the active window, but does not work with the newer modern/universal apps because
Starting from Win10 Anniversary Update ApplicationFrameHost child window return anything but UWP application. It worked only in Tablet mode after relogon.