mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
23 lines
631 B
C#
23 lines
631 B
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace Artemis.UI.Utilities
|
|
{
|
|
public static class WindowUtilities
|
|
{
|
|
public static int GetActiveProcessId()
|
|
{
|
|
// Get foreground window handle
|
|
IntPtr hWnd = GetForegroundWindow();
|
|
|
|
GetWindowThreadProcessId(hWnd, out uint processId);
|
|
return (int) processId;
|
|
}
|
|
|
|
[DllImport("user32.dll")]
|
|
private static extern IntPtr GetForegroundWindow();
|
|
|
|
[DllImport("user32.dll")]
|
|
private static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
|
|
}
|
|
} |