Пример #1
0
        /* Tools stuff */


        public bool TakeActiveWindowScreenshot(bool clientOnly)
        {
            if (windowsListener != null)
            {
                Window w = new Window(windowsListener.CurrentForegroundWindowHandle);

                ScreenshotTaker st         = new ScreenshotTaker();
                Bitmap          screenshot = st.Take(w, clientOnly, ScreenshotTaker.Mode.PrintScreen);

                try
                {
                    screenshot.Save(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\screenshot.png");
                }
                catch (Exception)
                {
                    return(false);
                }

                WriteDebug("--- Try to analize the screen shoot");

                // Table foundWindow = FindTableByWindowTitle(w.Title);

                Table foundWindow = FindTableByWindowHandle(w.handle);
                if (null != foundWindow && foundWindow.IsVisualRecognitionPossible())
                {
                    foundWindow.VisuallyProcessImage(screenshot);
                }
                else
                {
                    Globals.Director.WriteDebug(" ERROR: could not find table for window: " + w.Title);
                }

                return(true);
            }

            return(false);
        }