private void HandleWindowEvent_(WindowCaptureInfo oldContext, WindowEventArgs ev) { var wi = captureApi_.GetWindowInfo(ev.Window); if (wi == null) { context_ = null; return; } if (ev.EventType == GuiEventTypes.WindowActivated) { if (!MonitorHost && hostId_ == wi.Process) { context_ = null; return; } if (MonitorProcessesById != -1 && MonitorProcessesById != wi.Process) { context_ = null; return; } if (MonitorWindowsByTitle != null && !MonitorWindowsByTitle.IsMatch(wi.Caption)) { context_ = null; return; } if (MonitorProcessesByName != null) { if (oldContext == null || oldContext.Process != wi.Process || lastProcessName_ == null) { using (var process = Process.GetProcessById(wi.Process)) { lastProcessName_ = process.MainModule.ModuleName; } } if (!MonitorProcessesByName.IsMatch(lastProcessName_)) { context_ = null; return; } } } // Context must update on activation, resize and move. context_ = wi; logger_.Log("Capture context updated: {0} => {1}", ev.EventType, context_); }
private void HandleMouseEvent_(WindowCaptureInfo context, MouseEventArgs ev) { if (!context.Client.Contains(ev.Location)) { logger_.Verbose("Out of bounds: {0}", ev.ToString()); return; } ev.X -= context.Client.X; ev.Y -= context.Client.Y; ev.WindowSize = context.Client.Size; ev.X -= CapturePadding.Left; ev.Y -= CapturePadding.Top; logger_.Verbose(ev.ToString()); AddEvent_(ev); }