public MainWindow() { InitializeComponent(); KeyboardWatcher.Start(); KeyboardWatcher.OnKeyInput += (s, e) => { Debug.WriteLine(string.Format("Key {0} event of key {1}", e.KeyData.EventType, e.KeyData.Keyname)); }; MouseWatcher.Start(); MouseWatcher.OnMouseInput += (s, e) => { Debug.WriteLine(string.Format("Mouse event {0} at point {1},{2}", e.Message.ToString(), e.Point.x, e.Point.y)); }; ClipboardWatcher.Start(); ClipboardWatcher.OnClipboardModified += (s, e) => { Debug.WriteLine(string.Format("Clipboard updated with data '{0}' of format {1}", e.Data, e.DataFormat.ToString())); }; ApplicationWatcher.Start(); ApplicationWatcher.OnApplicationWindowChange += (s, e) => { Debug.WriteLine(string.Format("Application window of '{0}' with the title '{1}' was {2}", e.ApplicationData.AppName, e.ApplicationData.AppTitle, e.Event)); }; PrintWatcher.Start(); PrintWatcher.OnPrintEvent += (s, e) => { Debug.WriteLine(string.Format("Printer '{0}' currently printing {1} pages.", e.EventData.PrinterName, e.EventData.Pages)); }; }
static void Main(string[] args) { InitializeListener(); ApplicationWatcher.Start(); ApplicationWatcher.OnApplicationWindowChange += (sender, eventArgs) => { if (eventArgs.Event == ApplicationEvents.Closed) { return; } tagRECT windowRect; NativeMethods.GetWindowRect(eventArgs.ApplicationData.HWnd, out windowRect); var cx = windowRect.left + (windowRect.right - windowRect.left) / 2.0f; var cy = windowRect.top + (windowRect.bottom - windowRect.top) / 2.0f; var width = windowRect.right - windowRect.left; var height = windowRect.bottom - windowRect.top; var soundPosition = new Vector3f(cx / _screenSize.Width, cy / _screenSize.Height, 0); new Sound(_notificationSound) { Position = soundPosition, Attenuation = 2, Pitch = (_screenSize.Width * (float)_screenSize.Height) / (width * (float)height) * 0.25f, RelativeToListener = false }.Play(); }; Console.ReadLine(); ApplicationWatcher.Stop(); }
private void MainApplication(string[] args) { ApplicationWatcher applicationWatcher = new ApplicationWatcher(_logger); applicationWatcher.Deserialize(_configuration); //applicationWatcher.AddMonitoredApplication("MonitoredApplication", @"D:\DevelPers\WatchDog\MonitoredApplication\bin\Release\MonitoredApplication.exe",10,10,1,1,false,true,true,true); //var applicationHandler = new ApplicationHandler("MonitoredApplication", @"D:\DevelPers\WatchDog\MonitoredApplication\bin\Release\MonitoredApplication.exe", 10, 10, 1, 1,false, true) {Active = true}; //applicationWatcher.ApplicationHandlers.Add(applicationHandler); new MainFormVm(_mainForm, applicationWatcher, _configuration, _configurationSerializer); }
public MainWindow() { InitializeComponent(); Application.Current.Exit += OnApplicationExit; keyboardWatcher = eventHookFactory.GetKeyboardWatcher(); keyboardWatcher.Start(); keyboardWatcher.OnKeyInput += (s, e) => { Console.WriteLine("Key {0} event of key {1}", e.KeyData.EventType, e.KeyData.Keyname); }; mouseWatcher = eventHookFactory.GetMouseWatcher(); mouseWatcher.Start(); mouseWatcher.OnMouseInput += (s, e) => { Console.WriteLine("Mouse event {0} at point {1},{2}", e.Message.ToString(), e.Point.x, e.Point.y); }; clipboardWatcher = eventHookFactory.GetClipboardWatcher(); clipboardWatcher.Start(); clipboardWatcher.OnClipboardModified += (s, e) => { Console.WriteLine("Clipboard updated with data '{0}' of format {1}", e.Data, e.DataFormat.ToString()); }; applicationWatcher = eventHookFactory.GetApplicationWatcher(); applicationWatcher.Start(); applicationWatcher.OnApplicationWindowChange += (s, e) => { Console.WriteLine("Application window of '{0}' with the title '{1}' was {2}", e.ApplicationData.AppName, e.ApplicationData.AppTitle, e.Event); }; printWatcher = eventHookFactory.GetPrintWatcher(); printWatcher.Start(); printWatcher.OnPrintEvent += (s, e) => { Console.WriteLine("Printer '{0}' currently printing {1} pages.", e.EventData.PrinterName, e.EventData.Pages); }; eventHookFactory.Dispose(); }
static void Main(string[] args) { m_logger.Info(""); m_logger.Info("[NDaemon.App (Server)] starting."); ApplicationWatchdogDefinition applicationWatchdogDefinition = ApplicationWatchdogDefinitionBuilder.CreateFromConfiguration(); using (ApplicationWatcher watcher = new ApplicationWatcher(applicationWatchdogDefinition)) { using (new BackGroundColorSetting(ConsoleColor.DarkGreen)) { Console.WriteLine("To finish watchdog, press <Enter>."); } Console.ReadLine(); } m_logger.Info("[NDaemon.App (Server)] finished."); }
public MainWindow() { InitializeComponent(); if (Properties.Settings.Default["filePath"].ToString() != "") { filePath = Properties.Settings.Default["filePath"].ToString(); } else { filePath = Path.Combine(Environment.ExpandEnvironmentVariables("%userprofile%"), @"Videos\Observations"); } for (int i = 0; i < Screen.AllScreens.Length; i++) { ScreenBox.Items.Add("Display " + (i + 1)); } ScreenBox.SelectedIndex = currentScreen; ScreenBox.SelectionChanged += ScreenBox_SelectedIndexChanged; SelectLocationButton.Click += SelectLocationButton_Click; TrayRecordButton.Click += TrayRecordButton_Click; SettingsButton.Click += SettingsButton_Click; ClosingButton.Click += ClosingButton_Click; QuitButton.Click += QuitButton_Click; LocationEntry.Text = filePath; SystemEvents.SessionSwitch += SystemEvents_SessionSwitch; Hide(); #region Configure Event Handlers keyboardWatcher = eventHookFactory.GetKeyboardWatcher(); keyboardWatcher.Start(); keyboardWatcher.OnKeyInput += (s, e) => { string eventString = string.Format("Key {0} event of key {1}", e.KeyData.EventType, e.KeyData.Keyname); Dispatcher.BeginInvoke((Action)(() => { KeyboardEvents.Content = eventString; })); if (isRecording) { eventWriter.WriteEvent(EventWriter.InputEvent.Keyboard, eventString); } }; mouseWatcher = eventHookFactory.GetMouseWatcher(); mouseWatcher.Start(); mouseWatcher.OnMouseInput += (s, e) => { string eventString = string.Format("Mouse event {0} at point {1},{2}", e.Message.ToString(), e.Point.x, e.Point.y); Dispatcher.BeginInvoke((Action)(() => { MouseEvents.Content = eventString; })); if (isRecording) { if (e.Message.ToString() == "WM_LBUTTONDOWN" || e.Message.ToString() == "WM_RBUTTONDOWN") { eventWriter.WriteEvent(EventWriter.InputEvent.MouseClick, eventString); } else { if ((mousePosition[0] == 0 && mousePosition[1] == 0) || Math.Abs(e.Point.x - mousePosition[0]) >= minDistance || Math.Abs(e.Point.y - mousePosition[1]) >= minDistance) { mousePosition[0] = e.Point.x; mousePosition[1] = e.Point.y; eventWriter.WriteEvent(EventWriter.InputEvent.MouseMove, eventString); } } } }; clipboardWatcher = eventHookFactory.GetClipboardWatcher(); clipboardWatcher.Start(); clipboardWatcher.OnClipboardModified += (s, e) => { eventWriter.WriteEvent(EventWriter.InputEvent.Clipboard, e.Data.ToString()); }; applicationWatcher = eventHookFactory.GetApplicationWatcher(); applicationWatcher.Start(); applicationWatcher.OnApplicationWindowChange += (s, e) => { string eventString = string.Format("Application window of '{0}' with the title '{1}' was {2}", e.ApplicationData.AppName, e.ApplicationData.AppTitle, e.Event); Dispatcher.Invoke(() => { ApplicationEvents.Content = eventString; }); if (isRecording) { eventWriter.WriteEvent(EventWriter.InputEvent.Application, eventString); } }; printWatcher = eventHookFactory.GetPrintWatcher(); printWatcher.Start(); printWatcher.OnPrintEvent += (s, e) => { string eventString = string.Format("Printer '{0}' currently printing {1} pages.", e.EventData.PrinterName, e.EventData.Pages); Dispatcher.Invoke(() => { PrinterEvents.Content = eventString; }); if (isRecording) { eventWriter.WriteEvent(EventWriter.InputEvent.Print, eventString); } }; #endregion try { RegisterChromeExtension(); } catch (Exception e) { NotifyIcon.ShowBalloonTip("Exception", e.Message, BalloonIcon.Info); } }
public MainForm() { Application.ApplicationExit += OnApplicationExit; InitializeComponent(); keyboardWatcher = eventHookFactory.GetKeyboardWatcher(); keyboardWatcher.OnKeyInput += (s, e) => { if (e.KeyData.EventType.ToString() == "down") { current_time = DateTime.Now; Hashtable this_event = new Hashtable { { "Event Type", "Keyboard" }, { "Event Info", e.KeyData.Keyname }, { "Job id", job_id }, { "Resource", resource }, { "Form", GainActivatedForm() }, { "Timestamp", current_time.ToString("yyyy-MM-dd HH:mm:ss") + "." + current_time.Millisecond.ToString() } }; eventlog.Add(this_event); } }; mouseWatcher = eventHookFactory.GetMouseWatcher(); string[] MouseMoveMent = { "WM_WHEELBUTTONDOWN", "WM_LBUTTONDOWN", "WM_MOUSEWHEEL", "WM_WHEELBUTTONDOWN" }; mouseWatcher.OnMouseInput += (s, e) => { if (Array.IndexOf(MouseMoveMent, e.Message.ToString()) != -1) { current_time = DateTime.Now; string[] inter = GainMouseClickClassName(e.Point.x, e.Point.y); Hashtable this_event = new Hashtable { { "Event Type", "Mouse" }, { "Event Info", e.Message.ToString() }, { "Position", e.Point.x.ToString() + "|" + e.Point.y.ToString() }, { "Job id", job_id }, { "Resource", resource }, { "Form", GainActivatedForm() }, { "Click_Name", inter[1] }, { "Click_ClassName", inter[0] }, { "Timestamp", current_time.ToString("yyyy-MM-dd HH:mm:ss") + "." + current_time.Millisecond.ToString() } }; eventlog.Add(this_event); } ; }; applicationWatcher = eventHookFactory.GetApplicationWatcher(); applicationWatcher.OnApplicationWindowChange += (s, e) => { Hashtable this_event = new Hashtable { { "Event Type", "Application" }, { "Event Info", e.ApplicationData.AppName + "|" + e.ApplicationData.AppTitle + "|" + e.Event }, { "Job id", job_id }, { "Resource", resource }, { "Form", GainActivatedForm() }, { "Timestamp", current_time.ToString("yyyy-MM-dd HH:mm:ss") + "." + current_time.Millisecond.ToString() } }; eventlog.Add(this_event); //Console.WriteLine("Application window of '{0}' with the title '{1}' was {2}", // e.ApplicationData.AppName, e.ApplicationData.AppTitle, e.Event); }; clipboardWatcher = eventHookFactory.GetClipboardWatcher(); clipboardWatcher.OnClipboardModified += (s, e) => { Hashtable this_event = new Hashtable { { "Event Type", "Clipboard" }, { "Event Info", e.Data }, { "Job id", job_id }, { "Resource", resource }, { "Form", GainActivatedForm() }, { "Timestamp", current_time.ToString("yyyy-MM-dd HH:mm:ss") + "." + current_time.Millisecond.ToString() } }; eventlog.Add(this_event); //Console.WriteLine("Clipboard updated with data '{0}' of format {1}", e.Data, // e.DataFormat.ToString()); }; ////////////////////////////////////////////////////////////////// printWatcher = eventHookFactory.GetPrintWatcher(); printWatcher.OnPrintEvent += (s, e) => { Hashtable this_event = new Hashtable { { "Event Type", "Printer" }, { "Event Info", e.EventData.PrinterName }, { "Job id", job_id }, { "Resource", resource }, { "Form", GainActivatedForm() }, { "Timestamp", current_time.ToString("yyyy-MM-dd HH:mm:ss") + "." + current_time.Millisecond.ToString() } }; eventlog.Add(this_event); //Console.WriteLine("Printer '{0}' currently printing {1} pages.", e.EventData.PrinterName, // e.EventData.Pages); }; }