예제 #1
0
        /// <summary>
        /// Select the window to capture, this has logic which takes care of certain special applications
        /// like TOAD or Excel
        /// </summary>
        /// <param name="windowToCapture">WindowDetails with the target Window</param>
        /// <returns>WindowDetails with the target Window OR a replacement</returns>
        public static WindowDetails SelectCaptureWindow(WindowDetails windowToCapture)
        {
            Rectangle windowRectangle = windowToCapture.WindowRectangle;

            if (windowRectangle.Width == 0 || windowRectangle.Height == 0)
            {
                Log.WarnFormat("Window {0} has nothing to capture, using workaround to find other window of same process.", windowToCapture.Text);
                // Trying workaround, the size 0 arrises with e.g. Toad.exe, has a different Window when minimized
                WindowDetails linkedWindow = WindowDetails.GetLinkedWindow(windowToCapture);
                if (linkedWindow != null)
                {
                    windowToCapture = linkedWindow;
                }
                else
                {
                    return(null);
                }
            }
            return(windowToCapture);
        }