AppKit C# Wrapper for MacOS

[AppKit C# Wrapper for MacOS]

using MonoMac.AppKit;


namespace Blazor_MacOS_UI
{
    internal class NativeUtils
    {
        public static string GetActiveWindowTitle()
        {
            NSWorkspace sharedWorkspace = NSWorkspace.SharedWorkspace;
            NSRunningApplication currentApp = NSRunningApplication.CurrentApplication;

            // Get the process identifier of the frontmost (foreground) application
            int processIdentifier = currentApp.ProcessIdentifier;

            // Get the NSRunningApplication for the frontmost application
            NSRunningApplication frontmostApp = NSRunningApplication.GetRunningApplication(processIdentifier);

            // Get the localized name (title) of the frontmost application's main window
            string foregroundWindowTitle = frontmostApp.LocalizedName;

            return foregroundWindowTitle;
        }

    }
}