public static bool IsDesktopActive() { var gta = UtilInterop.FindWindow(null, "GTA:SA:MP"); if (gta != IntPtr.Zero) { return(gta != UtilInterop.GetForegroundWindow()); } return(false); }
private void ModuleWaitProcedure() { while (_moduleWaitRunning) { Thread.Sleep(TimeSpan.FromMilliseconds(50.0)); if (_processWatcher.WatchedProcess != null) { try { var gotModule = false; var moduleCollection = _processWatcher.WatchedProcess.Modules; foreach (ProcessModule item in moduleCollection) { if (item.ModuleName == "samp.dll" && UtilInterop.FindWindow(null, "GTA:SA:MP") != IntPtr.Zero) { InitializeAPI(); foreach (var component in _components) { component.ProcessStarted(); } _moduleWaitRunning = false; _gameRunning = true; gotModule = true; break; } } if (!gotModule) { _processWatcher.WatchedProcess.Refresh(); Thread.Sleep(500); } } catch (System.ComponentModel.Win32Exception) { } } else { _moduleWaitRunning = false; } } }