private void EventCallback(IntPtr hWinEventHook, uint iEvent, IntPtr hWnd, int idObject, int idChild, int dwEventThread, int dwmsEventTime) { if (iEvent == EVENT_SYSTEM_FOREGROUND || iEvent == EVENT_SYSTEM_MINIMIZEEND) { uint pid; GetWindowThreadProcessId(GetForegroundWindow(), out pid); TrackedWindow trackedWindow = TrackedWindow.From( Process.GetProcessById((int)pid), GetCaptionOf(hWnd)); if (trackedWindow != null) { var onNewActivity = OnNewTrackedWindow; if (onNewActivity == null) { return; } onNewActivity(this, new TrackedWindowEventArgs(trackedWindow)); } } }
public TrackedWindowEventArgs(TrackedWindow trackedWindow) { this.trackedWindow = trackedWindow; }