Example #1
0
        private void SetStudentRangeParameters(Point p, List <Tuple <string, string> > studentRanges, int numRetries = DEFAULT_RETRIES)
        {
            if (!EnoughRetries(numRetries) || !OpenColumnCondition(p))
            {
                Stuff.WriteConsoleError("Unable to set student range parameters");
                return;
            }

            Input.PressKey(Input.KEY_B);
            Input.PressKey(Input.KEY_TAB);

            int count = 0;

            foreach (Tuple <string, string> range in studentRanges)
            {
                Input.KeyboardWrite(range.Item1, 100);
                Input.PressKey(Input.KEY_TAB);
                Input.PressKey(Input.KEY_TAB);
                Input.KeyboardWrite(range.Item2, 100);
                Input.PressKey(Input.KEY_TAB);
                Input.PressKey(Input.KEY_TAB);
                Input.PressKey(Input.KEY_ENTER);

                if ((count + 1) != studentRanges.Count)
                {
                    Input.RegisterKeyDown(Input.KEY_SHIFT);
                    Input.PressKey(Input.KEY_TAB);
                    Input.PressKey(Input.KEY_TAB);
                    Input.PressKey(Input.KEY_TAB);
                    Input.PressKey(Input.KEY_TAB);
                    Input.RegisterKeyUp(Input.KEY_SHIFT);
                    count++;
                }
            }
            Input.RegisterKeyDown(Input.KEY_ALT);
            Input.PressKey(Input.KEY_C);
            Input.RegisterKeyUp(Input.KEY_ALT);
        }
Example #2
0
        // This method processes the main program. Main() ends up keeping track of whether it should kill
        // the program while this guy does all the actual hard work of drawing, checking mails, etc.
        static void ProcessStuff()
        {
            Stuff.Init();

            Account.Init();

            // Loads the font into memory from the .map files
            font = new CharFont("CharFiles/MizConsole/");
            Actions.Actions.Init(font);

            Thread.Sleep(1000);

            HwndObject obj;

            if (GetPaintHwnd(out obj))
            {
                Console.ForegroundColor = Colors.Success;
                Console.WriteLine("[Program] Paint Hwnd found! using: " + obj.Text);
                obj.Activate();
                WindowScrape.Static.HwndInterface.ShowWindow(obj.Hwnd, 3);
            }
            else
            {
                Console.ForegroundColor = Colors.Message;
                Console.WriteLine("[Program] Paint Hwnd not found.");
                Input.OpenPaint();
                if (!ForceGetPaintHwnd(out obj))
                {
                    Console.ForegroundColor = Colors.Error;
                    Console.WriteLine("[Program] ERROR: Can't find Paint Hwnd. Process aborted.");
                    return;
                }
            }

            Thread.Sleep(1000);

            if (obj.Location.X > 10 && obj.Location.Y > 10 && obj.Size.Width < Stuff.ScreenWidth - 50 && obj.Size.Height < Stuff.ScreenHeight - 50)
            {
                Console.ForegroundColor = Colors.Message;
                Console.WriteLine("Paint window not maximized, maximizing...");
                Input.MoveTo(new Point(obj.Location.X + obj.Size.Width - 69, obj.Location.Y + 3));
                Input.RegisterClick();
                Thread.Sleep(100);
            }

            watch = Stopwatch.StartNew();
            queue = new Queue <IAction>(64);
            Console.ForegroundColor = Colors.Success;
            Console.WriteLine("Stopwatch started. Entering main loop...");

            Input.PaintSelectBrush();
            new SimpleWrite(font, "Welcome to PaintDrawer! What shall I draw for you, kind sir?", 70).Act();

            System.Text.StringBuilder build = new System.Text.StringBuilder(256);
            for (int i = 32; i < CharFont.MaxCharNumericValue; i++)
            {
                if (font.DoesCharExist((char)i))
                {
                    build.Append((char)i);
                }
            }
            new SimpleWrite(font, build.ToString(), 70).Act();

            Actions.Actions.CreateSimpleWrite(font, "Este es un mensaje especial! Estas durmiendo en un estado de coma, metimos esto en tu cabeza pero no sabemos a donde va a terminar, no tenemos idea que hacer con vos, por favor despertate! no porque te extrañemos pero yo que se...").Act();
            LastDraw = -60;

            while (true)
            {
                Account.AddNewToQueue(queue);

                if (queue.Count == 0 && Time - LastDraw > 5 * 60)
                {
                    // More than X minutes passed since the last draw! Let's add something random then...
                    queue.Enqueue(Actions.Actions.RandomAction);
                }

                if (queue.Count != 0 && Time - LastDraw > 1 * 60)
                {
                    // Give all texts at least a minute before erasing 'em... and drawing something else
                    Input.PaintClearImage();
                    Input.PaintSelectBrush();
                    LastDraw = Time;
                    queue.Dequeue().Act();
                }
                else
                {
                    Thread.Sleep(2000);
                }
            }
        }
Example #3
0
        public static void MakeLineGroup(Point[] vertices)
        {
            if (vertices.Length == 0)
            {
                return;
            }

            float distToVertex = 0;
            float distLeft     = MoveDistance;
            int   index        = 0;

            while (true)
            {
#if PRINT_MOVES
                Console.ForegroundColor = Colors.Normal;
#endif

                distLeft     = MoveDistance;
                distToVertex = Stuff.Distance(Cursor.Position, vertices[index]);
                while (distLeft > 0)
                {
                    if (distLeft < distToVertex)
                    {
#if PRINT_MOVES
                        Console.WriteLine("[Input] (" + index + ") Moved by " + distLeft);
#endif
                        MoveBy(vertices[index], distLeft);
                        distLeft = 0;
                    }
                    else
                    {
                        while (distLeft >= distToVertex)
                        {
#if PRINT_MOVES
                            Console.WriteLine("[Input] (" + index + ") Closed at " + distToVertex);
#endif
                            distLeft       -= distToVertex;
                            Cursor.Position = vertices[index];
                            index++;
                            if (index == vertices.Length)
                            {
#if PRINT_MOVES
                                Console.WriteLine("[Input] Linegroup size " + vertices.Length + " done.");
#endif
                                MouseUp();
                                return;
                            }
                            else if (index == 1)
                            {
                                MouseDown();
                            }
                            distToVertex = Stuff.Distance(Cursor.Position, vertices[index]);
                        }
                    }
                }

#if PRINT_MOVES
                Console.ForegroundColor = Colors.Message;
                Console.WriteLine("[Input] slept.");
#endif
                Thread.Sleep(SLPTime);
            }
        }
Example #4
0
        public void SaveExcel(string path)
        {
            HwndObject window = HwndObject.GetForegroundWindow();

            if (!window.Title.Contains("Excel") && !window.Title.StartsWith("Book"))
            {
                foreach (HwndObject o in HwndObject.GetWindows().FindAll(e => e.Title.Contains("Excel")))
                {
                    if (o.Title.StartsWith("Book"))
                    {
                        if (window == null)
                        {
                            window = o;
                        }
                        else if (Int32.TryParse(o.Title.Substring(4), out int number))
                        {
                            if (number > Int32.Parse(window.Title.Substring(4)))
                            {
                                window = o;
                            }
                        }
                    }
                }
            }

            if (window == null)
            {
                Console.ForegroundColor = Colors.Error;
                Console.WriteLine("Unable to export report from Axium");
                return;
            }
            else
            {
                Console.ForegroundColor = Colors.Success;
                Console.WriteLine("Excel file opened: " + window.Title);
            }

            window.Activate();
            Thread.Sleep(2000);
            window.Maximize();
            Thread.Sleep(2000);
            Input.PressKeyCombo(Input.KEY_CONTROL, Input.KEY_S);
            Thread.Sleep(2000);

            Input.MoveTo(new Point(800, 635));
            Thread.Sleep(500);
            Input.RegisterClick();
            Thread.Sleep(500);

            Input.MoveTo(new Point(570, 195));
            Thread.Sleep(500);
            Input.RegisterClick();
            Thread.Sleep(500);

            HwndObject saveDialog = HwndObject.GetWindows().Find(e => e.Title.Contains("Save As"));

            Stuff.WriteConsoleMessage("Save dialog found!");
            saveDialog.Activate();
            Thread.Sleep(500);
            Input.KeyboardWrite(path, 100);
            Thread.Sleep(100);
            Input.PressKeyCombo(Input.KEY_ALT, Input.KEY_S);
            Thread.Sleep(2000);

            if (!File.Exists(path + ".xlsx"))
            {
                Stuff.WriteConsoleError("File was not saved...trying again");
            }
            else
            {
                window.CloseWindow();
                Stuff.WriteConsoleSuccess("File was saved to " + path);
            }
        }
Example #5
0
        private void ExportQuery()
        {
            Input.PressKeyCombo(Input.KEY_ALT, Input.KEY_A);
            Thread.Sleep(5000);

            HwndObject startWindow = HwndObject.GetForegroundWindow();

            Input.PressKeyCombo(Input.KEY_ALT, Input.KEY_E);
            Thread.Sleep(1000);

            Input.MoveTo(new Point(870, 405));
            Input.RegisterClick();
            Thread.Sleep(500);
            Input.PressKeyCombo(Input.KEY_ALT, Input.KEY_O);

            Stopwatch watch = Stopwatch.StartNew();

            Thread.Sleep(10000);

            HwndObject progress = null;

            foreach (HwndObject o in HwndObject.GetWindows())
            {
                List <HwndObject> list = o.GetChildren();
                if (list.Count <= 1)
                {
                    continue;
                }

                if (list[1].Title.Equals("Processing"))
                {
                    Stuff.WriteConsoleMessage(Stuff.GetHwndInfoString(list[0]));
                    progress = list[0];
                    break;
                }
            }

            int excelWindowCount = HwndObject.GetWindows().FindAll(e => e.Title.Contains("Excel")).Count;

            while (true)
            {
                HwndObject window = HwndObject.GetForegroundWindow();
                if (window.Title.Contains("Excel") && window.Title.StartsWith("Book"))
                {
                    Stuff.WriteConsoleMessage("Found opened window");
                    break;
                }
                else if (HwndObject.GetWindows().FindAll(e => e.Title.Contains("Excel")).Count == (excelWindowCount + 1))
                {
                    Stuff.WriteConsoleMessage("Detected change in excel window counts");
                    break;
                }

                Console.Write("Waiting... (" + watch.ElapsedMilliseconds + ")");
                if (progress != null)
                {
                    Console.WriteLine(" " + progress.Text);
                }
                else
                {
                    Console.WriteLine();
                }
                Thread.Sleep(5000);
            }
            watch.Stop();

            Stuff.WriteConsoleSuccess("Data exported");
        }
Example #6
0
        public void RunAppointmentReport(string path, string startDate, string endDate, List <Tuple <string, string> > studentRanges, int numRetries = DEFAULT_RETRIES)
        {
            if (!EnoughRetries(numRetries))
            {
                return;
            }

            CloseInfoManager();
            if (GetInfoManager() == null)
            {
                Stuff.WriteConsoleError("Unable to open info manager...Giving Up");
                return;
            }

            Input.MoveTo(new Point(480, 95)); // Appointment Tab
            Thread.Sleep(500);
            Input.RegisterClick();
            Thread.Sleep(500);

            Input.MoveTo(new Point(1060, 170)); // Pre-Defined Button
            Thread.Sleep(500);
            Input.RegisterClick();
            Thread.Sleep(1000);

            Input.MoveTo(new Point(845, 500)); // Michael's Appointment List
            Thread.Sleep(500);
            Input.RegisterClick();
            Thread.Sleep(1000);

            Input.PressKeyCombo(Input.KEY_ALT, Input.KEY_S); // Select the report

            Stuff.WriteConsoleMessage("Setting date range of " + startDate + " to " + endDate);
            SetDateFieldParameters(new Point(335, 350), startDate, endDate);
            Thread.Sleep(500);

            Stuff.WriteConsoleMessage("Setting student ranges");
            studentRanges.Add(Tuple.Create("D106", "D106")); //NPE
            studentRanges.Add(Tuple.Create("D099", "D099")); //ER
            SetStudentRangeParameters(new Point(560, 350), studentRanges);
            Thread.Sleep(500);

            if (!new RetryableAction(() => ExecuteQuery(), "Executing Query").Execute())
            {
                Stuff.WriteConsoleError("Unable to execute query to gather appointments");
                return;
            }
            Thread.Sleep(5000);

            GetInfoManager().Activate();
            if (!new RetryableAction(() => ExportQuery(), "Exporting Query Results").Execute())
            {
                Stuff.WriteConsoleError("Unable to export query results");
                return;
            }
            Thread.Sleep(5000);

            if (!new RetryableAction(() => SaveExcel(path), "Saving Generated Excel File").Execute())
            {
                Stuff.WriteConsoleError("Unable to save excel file");
                return;
            }
            Thread.Sleep(5000);
        }