public void Init()
 {
     Language.Addon addon = Language.Addon.Load(@"G1ANT.Addon.Ocr.AbbyyFineReader.dll");
     scripter = new Scripter();
     scripter.InitVariables.Clear();
     testerApp = AbbyTests.StartFormTester($"Title {appTitle}");
 }
        public void FindWindowTitleTest()
        {
            string   appTitle = "TestApp";
            Scripter scripter = new Scripter();

            scripter.InitVariables.Clear();
            System.Diagnostics.Process testerApp       = null;
            List <GStruct.Structure>   windowTitleRect = null;

            try
            {
                scripter = new Scripter();
                scripter.InitVariables.Clear();
                testerApp = AbbyTests.StartFormTester($"Title {appTitle}");
                IntPtr          hTesterAppWindow = testerApp.MainWindowHandle;
                RobotWin32.Rect windowRect       = new RobotWin32.Rect();
                RobotWin32.GetWindowRectangle(hTesterAppWindow, ref windowRect);
                int titleBarHeight = 24;

                scripter.Text = ($@"ocrabbyy.processscreen area {SpecialChars.Text}{windowRect.Left},{windowRect.Top},{windowRect.Right},{windowRect.Bottom}{SpecialChars.Text}
                                    ocrabbyy.find {SpecialChars.Text}{appTitle}{SpecialChars.Text} result {nameof(windowTitleRect)}");
                scripter.Run();
                windowTitleRect = scripter.Variables.GetVariableValue <List <GStruct.Structure> >(nameof(windowTitleRect));
                Assert.AreNotEqual(0, windowTitleRect.Count);
                System.Drawing.Rectangle titleRect = ((GStruct.RectangleStructure)windowTitleRect[0]).Value;

                Assert.IsTrue(titleRect.Top > 0 & titleRect.Top < titleBarHeight, "Top edge position of found rectangle is incorrect");
                Assert.IsTrue(titleRect.Bottom > 0 & titleRect.Bottom <= titleBarHeight, "Bottom edge position of found rectangle is incorrect");
                Assert.IsTrue(titleRect.Left > 0 & titleRect.Left < 50, "Left edge position of found rectangle is incorrect");
                Assert.IsTrue(titleRect.Right > 0 & titleRect.Right < windowRect.Right);
            }
            finally
            {
                if (testerApp != null && !testerApp.HasExited)
                {
                    testerApp.Kill();
                }
            }
        }