public static Process GetForegroundProcess()
        {
            IntPtr handle = Pinvokes.GetForegroundWindow();

            Pinvokes.GetWindowThreadProcessId(handle, out var procId);

            if (procId == -1)
            {
                return(null);
            }

            return(Process.GetProcessById(procId));
        }