private void TimerCountdown(object sender, EventArgs e) { string filepath = Path.Combine(ConstantValues.KEYBOARD_DATA_FILEPATH, ConstantValues.KEYBOARD_FILE_NAME); dataFormatter.RemoveLastDataItem(); List <KeysData> dataToWriteToFile = dataFormatter.DataRecorded; if (dataToWriteToFile.Count != 0) { PythonInterface pi = new PythonInterface(); List <string> formattedData = new List <string>(); foreach (KeysData keysData in dataToWriteToFile) { formattedData.Add(DataFormatter.GetFormattedDataLine(keysData)); } if (ModelFileExists()) { pi.TestUserInput(formattedData, health, ConstantValues.KEYBOARD_DATA_FILEPATH); } if (recordingEnabled.Checked) { WriteEncryptedDataToFile(filepath, dataToWriteToFile); } } PossiblyShuffleLines(filepath); if (health.GetValue() < ConstantValues.HEALTH_VALUE_THRESHOLD) { // Uncomment to lock user out of computer //Process.Start(@"C:\WINDOWS\system32\rundll32.exe", "user32.dll,LockWorkStation"); health.SetValue(ConstantValues.DEFAULT_HEALTH_VALUE); } dataFormatter.End(); }
public Emlin() { _proc = HookCallback; _hookID = SetHook(_proc); InitializeComponent(); CustomTimer timer = new CustomTimer(ConstantValues.LENGTH_OF_SESSION_IN_MILLIS); timer.Elapsed += TimerCountdown; timer.AutoReset = false; dataFormatter = new DataFormatter(timer); #if DEBUG devWindow.Show(); #endif health = new HealthSubject(); healthGraphView.SetHealthSubject(health); health.Attach(healthGraphView); health.SetValue(ConstantValues.DEFAULT_HEALTH_VALUE); }