This commit is contained in:
TinyHerm committed 2026-11-24 23:40:08 +03:00
commit 1c7a8cf25f
579 files changed
+83196

No files matched your search

@@ -0,0 +1,37 @@
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace VibranceHud.Fullscreen;
public static class ForegroundWindowProcess
{
[DllImport("user32.dll")]
private static extern nint GetForegroundWindow();
[DllImport("user32.dll")]
private static extern uint GetWindowThreadProcessId(nint hWnd, out uint processId);
public static string? Name()
{
try
{
nint foregroundWindow = GetForegroundWindow();
if (foregroundWindow == IntPtr.Zero)
{
return null;
}
if (GetWindowThreadProcessId(foregroundWindow, out var processId) == 0 || processId == 0)
{
return null;
}
using Process process = Process.GetProcessById((int)processId);
string processName = process.ProcessName;
return string.IsNullOrEmpty(processName) ? null : processName;
}
catch
{
return null;
}
}
}