private void OnWindowWatcherWindowExists(WindowData windowData)
        {
            Action action = () =>
            {
                if (windowData.Name != WindowName)
                    return;
                WindowWatcher.Instance.WindowExists -= OnWindowWatcherWindowExists;
                Update();
            };

            Dispatcher.BeginInvoke(action);
        }
Example #2
0
        private bool EnumWindowsProc(IntPtr hWnd, int lParam)
        {
            int textLength = Win32.User32.GetWindowTextLength(hWnd);

            var windowTextBuffer = new StringBuilder(textLength + 1);
            Win32.User32.GetWindowText(hWnd, windowTextBuffer, windowTextBuffer.Capacity);

            var windowText = windowTextBuffer.ToString();
            if (!string.IsNullOrEmpty(windowText))
            {
                var windowData = new WindowData(hWnd, windowText);
                m_currentWindows.Add(windowData.Handle, windowData);
            }

            return true;
        }