Beispiel #1
0
        public static void FocusWindowByText(string text)
        {
            UserApi.EnumWindows(delegate(IntPtr hwnd, int LParam)
            {
                StringBuilder windowTextHolder = new StringBuilder(1024, 1024);

                UserApi.GetWindowText(hwnd, windowTextHolder, windowTextHolder.Capacity);

                if (windowTextHolder.ToString() == text)
                {
                    UserApi.SetForegroundWindow(hwnd);
                    return(0);
                }

                return(1);
            }, 0);
        }