/// <summary>
        /// Called any time the active window changes.
        /// Checks if the program belonging to the new window can be determined.
        /// If it can be determined an event is sent out with the name of the window attached to it.
        /// </summary>
        /// <param name="hWinEventHook"></param>
        /// <param name="eventType"></param>
        /// <param name="hwnd"></param>
        /// <param name="idObject"></param>
        /// <param name="idChild"></param>
        /// <param name="dwEventThread"></param>
        /// <param name="dwmsEventTime"></param>
        public void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
        {
            IntPtr Handle;
            long   HandleLong;

            // Check if parent exists, if it does use it (meaning the active window is only a sub window)
            IntPtr NewParent = GetParent(hwnd);
            IntPtr OldParent = hwnd;

            while (NewParent.ToInt64() > 0)
            {
                OldParent = NewParent;
                NewParent = GetParent(OldParent);
            }

            Handle     = OldParent;
            HandleLong = hwnd.ToInt64();

            if (HandleLong <= 0)
            {
                return;
            }

            string windowTitle = GetActiveWindowTitle(Handle);

            if (windowTitle == null)
            {
                return;
            }

            ProgramChanged?.Invoke(this, new CustomEventArgs(windowTitle));
        }
示例#2
0
        void IBMDSwitcherInputCallback.Notify(_BMDSwitcherInputEventType eventType)
        {
            switch (eventType)
            {
            case _BMDSwitcherInputEventType.bmdSwitcherInputEventTypeLongNameChanged:
                NameChanged?.Invoke(this, null);
                break;

            case _BMDSwitcherInputEventType.bmdSwitcherInputEventTypeIsProgramTalliedChanged:
                ProgramChanged?.Invoke(this, null);
                break;

            case _BMDSwitcherInputEventType.bmdSwitcherInputEventTypeIsPreviewTalliedChanged:
                PreviewChanged?.Invoke(this, null);
                break;
            }
        }