mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-06 14:46:04 +02:00
separate isGameRunning and isGmaeNoVR
This commit is contained in:
@@ -46,31 +46,38 @@ namespace VRCX
|
||||
: string.Empty;
|
||||
}
|
||||
|
||||
public bool IsGameRunning()
|
||||
public bool[] CheckGameRunning()
|
||||
{
|
||||
IntPtr hwnd = WinApi.FindWindow("UnityWndClass", "VRChat");
|
||||
if (hwnd == IntPtr.Zero)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var isGameRunning = false;
|
||||
var isGameNoVR = false;
|
||||
|
||||
String cmdline;
|
||||
try
|
||||
var hwnd = WinApi.FindWindow("UnityWndClass", "VRChat");
|
||||
if (hwnd != IntPtr.Zero)
|
||||
{
|
||||
Int32 pid;
|
||||
WinApi.GetWindowThreadProcessId(hwnd, out pid);
|
||||
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT CommandLine FROM Win32_Process WHERE ProcessId = " + pid))
|
||||
using (ManagementObjectCollection objects = searcher.Get())
|
||||
var cmdline = string.Empty;
|
||||
try
|
||||
{
|
||||
cmdline = objects.Cast<ManagementBaseObject>().SingleOrDefault()?["CommandLine"]?.ToString();
|
||||
Int32 pid = 0;
|
||||
WinApi.GetWindowThreadProcessId(hwnd, out pid);
|
||||
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT CommandLine FROM Win32_Process WHERE ProcessId = " + pid))
|
||||
using (ManagementObjectCollection objects = searcher.Get())
|
||||
{
|
||||
cmdline = objects.Cast<ManagementBaseObject>().SingleOrDefault()?["CommandLine"]?.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
isGameRunning = true;
|
||||
isGameNoVR = cmdline.Contains("--no-vr");
|
||||
}
|
||||
|
||||
return !cmdline.Contains("--no-vr");
|
||||
return new bool[]
|
||||
{
|
||||
isGameRunning,
|
||||
isGameNoVR
|
||||
};
|
||||
}
|
||||
|
||||
public void StartGame(string arguments)
|
||||
|
||||
Reference in New Issue
Block a user