private void GlobalHotkeyListener_Load(object sender, EventArgs e) {//Checks if warframe is running, if not, adds watchers try { trayIcon = new SystemTrayIcon(this); trayIcon.Initialize(); processDetector = new ProcessDetector(new string[] { "Notepad", "Notepad.x64" }, WarframeIsRunning); processDetector.Start(); } catch (SystemTrayIconException a) { string temp = a.Message; if (a.InnerException != null) { temp += "\nInner Message: " + a.InnerException.Message; } MessageBox.Show(this, temp, "System Tray Icon Error"); this.Close(); } catch (ProcessDetectorException a) { string temp = a.Message; if (a.InnerException != null) { temp += "\nInner Message: " + a.InnerException.Message; } MessageBox.Show(this, temp, "Process Detector Error"); this.Close(); } }
private void WarframeIsRunning(Process warframe) { try { warframeProcess = warframe; warframeProcess.Exited += new EventHandler(TargetProcess_Exited); warframeProcess.EnableRaisingEvents = true; queryHandler = new WarframeQueryHandler(); processDetector = null; if (this.InvokeRequired) //Registers the hotkey { this.Invoke(new MethodInvoker(delegate { RegisterTriggerKey(Properties.Settings.Default.Key_Value, Properties.Settings.Default.Modifier_Value); })); } else { RegisterTriggerKey(Properties.Settings.Default.Key_Value, Properties.Settings.Default.Modifier_Value); } trayIcon.SetTextSuccess(); } catch (NullReferenceException e) { MessageBox.Show(e.Message, "Process Assignment Error"); this.Close(); } } //called if Warframe has been detected
public GlobalHotkeyListener() { InitializeComponent(); this.WindowState = FormWindowState.Minimized; this.Hide(); //Makes it not show up on taskbar this.TopLevel = false; //Makes it not show up under Apps in Task Manager trayIcon = null; //Shows the system tray icon processDetector = null; queryHandler = null; warframeProcess = null; mainTrigger = null; }