forked from KyeOnDiscord/Fortnite-Music-Changer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ForegroundWindow.cs
34 lines (32 loc) · 1.03 KB
/
ForegroundWindow.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace ProSwapperMusic
{
public class Pro
{
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
private static extern IntPtr GetForegroundWindow();
private const string fnproc = "FortniteClient-Win64-Shipping";
public static bool IsFNFocused
{
get
{
try
{
var activatedHandle = GetForegroundWindow();
Process[] processes = Process.GetProcessesByName(fnproc);
foreach (Process proc in processes)
{
if (activatedHandle == proc.MainWindowHandle && proc.ProcessName == fnproc)
{
return true;
}
}
}
catch {}
return false;
}
}
}
}