示例#1
0
        public FunctionCall wait(string arg_txt)
        {
            NumberGenerator rn = NumberGenerator.Parse(arg_txt);

            return(delegate()
            {
                BotHelpers.Wait(rn.GetInt());
                return FunctionResult.Continue;
            });
        }
示例#2
0
        public FunctionCall rightclick(string arg_txt)
        {
            NumberGenerator rn = NumberGenerator.Parse(arg_txt);

            return(delegate()
            {
                script.MouseMover.RightButton.Click(rn.GetInt());
                return FunctionResult.Continue;
            });
        }
示例#3
0
        public FunctionCall movefrom(string arg_txt)
        {
            string[]        args = arg_txt.Split(',');
            NumberGenerator x    = NumberGenerator.Parse(args[0]);
            NumberGenerator y    = NumberGenerator.Parse(args[1]);

            return(delegate()
            {
                script.MouseMover.MoveFrom(x.GetInt(), y.GetInt());
                return FunctionResult.Continue;
            });
        }
示例#4
0
        public FunctionCall rightclickat(string arg_txt)
        {
            string[]        args = arg_txt.Split(',');
            NumberGenerator x    = NumberGenerator.Parse(args[0]);
            NumberGenerator y    = NumberGenerator.Parse(args[1]);

            return(delegate()
            {
                script.MouseMover.MoveToAndClick(x.GetInt(),
                                                 y.GetInt(), script.MouseMover.RightButton, script.MouseSpeed.GetDouble());
                return FunctionResult.Continue;
            });
        }
示例#5
0
        public FunctionCall move(string arg_txt)
        {
            string[]        args = arg_txt.Split(',');
            NumberGenerator X    = NumberGenerator.Parse(args[0]);
            NumberGenerator Y    = NumberGenerator.Parse(args[1]);

            return(delegate()
            {
                script.MouseMover.MoveTo(X.GetInt() + script.XRef,
                                         Y.GetInt() + script.YRef, script.MouseSpeed.GetDouble());
                return FunctionResult.Continue;
            });
        }
示例#6
0
 /// <summary>
 /// Executes a series of <see cref="FunctionCall"/>s
 /// </summary>
 /// <param name="calls"></param>
 /// <returns>True if script all lines in the script were executed.
 /// False if the script terminated.</returns>
 bool ExecuteScript(IEnumerable <FunctionCall> calls)
 {
     foreach (FunctionCall call in calls)
     {
         FunctionResult result = call();
         BotHelpers.Wait(StandardWait.GetInt());
         if (result == FunctionResult.Break)
         {
             // don't continue with script
             return(false);
         }
     }
     return(true); // script completed
 }
示例#7
0
        public FunctionCall iftimer(string arg_txt)
        {
            string[]        args        = arg_txt.Split(',');
            NumberGenerator TimeSeconds = NumberGenerator.Parse(args[0]);
            string          file_path   = (args.Length > 1 ? args[1] : null);

            return(delegate()
            {
                if ((DateTime.Now - script.DynamicTimerStart).TotalSeconds > TimeSeconds.GetInt())
                {
                    return ExecFileBreakable(file_path);
                }
                return FunctionResult.Continue;
            });
        }
示例#8
0
        public FunctionCall loop(string arg_txt)
        {
            string[]        args      = arg_txt.Split(',');
            NumberGenerator repeats   = NumberGenerator.Parse(args[0]);
            string          file_path = args[1];

            return(delegate()
            {
                int loops = repeats.GetInt();
                for (int i = 0; i < loops; i++)
                {
                    script.ExecuteFile(file_path);
                }
                return FunctionResult.Continue;
            });
        }
示例#9
0
        public FunctionCall waitforpx(string arg_txt)
        {
            string[]        args          = arg_txt.Split(',');
            int             x             = Int32.Parse(args[0]);
            int             y             = Int32.Parse(args[1]);
            ColorChecker    color_checker = ColorRule.Parse(args[2]);
            NumberGenerator timeout_ms    = (args.Length > 3 ? NumberGenerator.Parse(args[3]) : new StaticNumber(0));
            string          file_path     = (args.Length > 4 ? args[4] : null);

            return(delegate()
            {
                if (!screen_color_detector.WaitForPx(new Point(x + script.XRef, y + script.YRef),
                                                     color_checker, timeout_ms.GetInt()))
                {
                    // timed out
                    return ExecFileBreakable(file_path);
                }
                return FunctionResult.Continue;
            });
        }
示例#10
0
        public FunctionCall movetocolor(string arg_txt)
        {
            string[]        args          = arg_txt.Split(',');
            NumberGenerator x1            = NumberGenerator.Parse(args[0]);
            NumberGenerator y1            = NumberGenerator.Parse(args[1]);
            NumberGenerator x2            = NumberGenerator.Parse(args[2]);
            NumberGenerator y2            = NumberGenerator.Parse(args[3]);
            ColorChecker    color_checker = ColorRule.Parse(args[4]);
            NumberGenerator timeout       = new StaticNumber(0);

            string file_path = null;

            if (args.Length > 5)
            {
                timeout = NumberGenerator.Parse(args[5]);
                if (args.Length > 6)
                {
                    file_path = args[6];
                }
            }

            return(delegate()
            {
                if (!script.MouseMover.MoveToColor(
                        Rectangle.FromLTRB(x1.GetInt() + script.XRef,
                                           y1.GetInt() + script.YRef,
                                           x2.GetInt() + script.XRef,
                                           y2.GetInt() + script.YRef),
                        color_checker, timeout.GetInt(), script.MouseSpeed.GetDouble()))
                {
                    // timed out
                    return ExecFileBreakable(file_path);
                }

                return FunctionResult.Continue;
            });
        }
示例#11
0
        public FunctionCall waitforarea(string arg_txt)
        {
            string[]        args              = arg_txt.Split(',');
            int             x1                = Int32.Parse(args[0]);
            int             y1                = Int32.Parse(args[1]);
            int             x2                = Int32.Parse(args[2]);
            int             y2                = Int32.Parse(args[3]);
            byte            tolerance         = byte.Parse(args[4]);
            int             pixel_requirement = Int32.Parse(args[5]);
            NumberGenerator timeout_ms        = (args.Length > 6 ? NumberGenerator.Parse(args[6]) : new StaticNumber(0));
            string          file_path         = (args.Length > 7 ? args[7] : null);

            return(delegate()
            {
                if (!screen_color_detector.WaitForAreaChange(Rectangle.FromLTRB(
                                                                 x1 + script.XRef, y1 + script.YRef,
                                                                 x2 + script.XRef, y2 + script.YRef
                                                                 ), pixel_requirement, timeout_ms.GetInt(),
                                                             ColorCompare.TolerantWithin(tolerance)))
                {
                    // timed out
                    return ExecFileBreakable(file_path);
                }
                return FunctionResult.Continue;
            });
        }