示例#1
0
        /// <summary>
        /// Find and return a handle on the first window with the specified title.
        /// </summary>
        /// <param name="windowTitle">The title of the window.</param>
        /// <returns>The handle to the window.</returns>
        public static IntPtr Get(string windowTitle)
        {
            IntPtr hWnd = WinAPI.FindWindow(null, windowTitle);

            if (hWnd == IntPtr.Zero)
            {
                throw new Exception("Window not found.");
            }
            return(hWnd);
        }
示例#2
0
        /// <summary>
        /// Check if a particular window is open.
        /// </summary>
        /// <param name="windowTitle">The title of the window.</param>
        /// <returns>True if the window is open.</returns>
        public static bool DoesExist(string windowTitle)
        {
            IntPtr hWnd = WinAPI.FindWindow(null, windowTitle);

            return(hWnd != IntPtr.Zero);
        }