Ejemplo n.º 1
0
        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));
                }
            }
        }
Ejemplo n.º 2
0
 public TrackedWindowEventArgs(TrackedWindow trackedWindow)
 {
     this.trackedWindow = trackedWindow;
 }