Exemplo n.º 1
0
        public static double[] GetImageCoordinates(string path, string[] prop)
        {
            AnalyzeScreen a   = new AnalyzeScreen();
            var           ret = a.GetScreenCoords(path.UnCleanString(), prop);

            return(ret);
        }
Exemplo n.º 2
0
        public static void AnalyzeScreen(string success, IBaseFunction successAction, IBaseFunction failureAction, string[] prop, TFunction caller = null)
        {
            var tfunc = new TFunction(caller.Function, new List <EDefinition>(), string.Join(",", caller.Function.GetInvokeProperties()), caller.CallingFunction);

            try
            {
                bool   finished = false;
                bool   func     = false;
                Thread th       = new Thread(() =>
                {
                    AnalyzeScreen ascreen = new AnalyzeScreen();
                    ascreen.Analyze(success.UnCleanString(),
                                    () => { finished = true; func = true; },
                                    () => { finished = true; },
                                    prop
                                    );
                });
                th.Start();
                Stopwatch watch = new Stopwatch();
                watch.Start();
                while (finished == false)
                {
                    if (TokenParser.Stop)
                    {
                        break;
                    }
                    Thread.Sleep(1000); //sleep for 1 second before checking again
                                        //if 30 seconds go by, then break and kill the thread
                    if (watch.Elapsed.TotalMilliseconds >= 45000)
                    {
                        Compiler.ExceptionListener.ThrowSilent(new ExceptionHandler(ExceptionType.SystemException,
                                                                                    $"CheckScreen() timed out."));
                        //smash the thread and move on. we dont care about that data anyway
                        try { th.Abort(); } catch (Exception e) { if (!(e is ThreadAbortException))
                                                                  {
                                                                      throw;
                                                                  }
                        }
                        break;
                    }
                }
                watch.Stop();
                if (func)
                {
                    successAction.TryParse(tfunc);
                }
                else
                {
                    failureAction.TryParse(tfunc);
                }
            }
            catch
            {
                Compiler.ExceptionListener.ThrowSilent(new ExceptionHandler("[63]Image check failed to execute. Continuing with failure function"));
                failureAction.TryParse(tfunc);
            }
        }
Exemplo n.º 3
0
        public override string CallBase()
        {
            var arg = ProvidedArgs.First("arr");

            if (arg == null)
            {
                Compiler.ExceptionListener.Throw($"Arguments for {this.Name} must not be null");
                return(null);
            }
            var args = new TArray("", arg.ToString(), "");

            if (args.Arguments == null)
            {
                Compiler.ExceptionListener.Throw($"Arguments for {this.Name} must be an array");
                return(null);
            }
            var props = new List <string>();

            props.AddRange(args.Arguments);
            var ret = AnalyzeScreen.SetDefaultTemplateOptions(props.ToArray());

            ReturnBubble = new TArray("templateOptions", ret, "");
            return("");
        }