private void KEY_LOGGER_KEY_PRESSED_EVENT(object sender, EventArgs e) //Event setup in KEY_LOGGER_SETUP. { if (REPLAY_SEQUENCE_ACTIVE) //Check if the replay sequence is active... { if ((string)sender == "{INSERT}") { REPLAY(SEQUENCE_LIST, INJECTION_TABLE); SendKeys.SendWait("{INSERT}"); //Since insert is a latched key, we need to turn it back. System.Threading.Thread.Sleep(75); //Delay a bit. } if ((string)sender == "{ESC}") { REPLAY_SEQUENCE_STOP(null, null); //Check if form is open. FormCollection COLLECTION = Application.OpenForms; //Get a collection of all the open forms. foreach (Form FORM in COLLECTION) //Go through each open form... { if (FORM.Name == "FORM_REPLAY") //If the evaluated form has the same name as the form we're about to open... { FORM.Close(); return; } } } } }