Example #1
0
        private void ClearOpenReports()
        {
            List <HwndObject> list = HwndObject.GetWindows().FindAll(o => o.Title.Equals("Enter Parameter Values"));

            foreach (HwndObject o in list)
            {
                o.CloseWindow();
                Thread.Sleep(1000);
                Input.PressKey(Input.KEY_SPACE);
                axiUm.Activate();
            }
        }
Example #2
0
        public AxiUmPuppet(HwndObject axiUm)
        {
            Stuff.Init();
            Thread.Sleep(1000);

            this.axiUm = axiUm;
            axiUm.Activate();
            WindowScrape.Static.HwndInterface.ShowWindow(axiUm.Hwnd, 3);
            Thread.Sleep(1000);

            // Maximize AxiUm if it already isn't
            axiUm.Maximize();

            // Close any open reports to ensure axiUm is in its default resting state
            ClearOpenReports();
        }
Example #3
0
        private bool OpenColumnCondition(Point p, int numRetries = DEFAULT_RETRIES)
        {
            if (!EnoughRetries(numRetries))
            {
                return(false);
            }

            Input.MoveTo(p);
            Thread.Sleep(500);
            Input.RegisterClick();
            Thread.Sleep(2000);

            HwndObject conditions = null;

            foreach (HwndObject o in HwndObject.GetWindows())
            {
                if (o.Title.Equals("Column Conditions"))
                {
                    conditions = o;
                    break;
                }
            }
            if (conditions == null)
            {
                Console.ForegroundColor = Colors.Error;
                Console.WriteLine("Unable to find Column Conditions box");
                Console.WriteLine("Not enough time to find these windows. Trying once more...");
                return(OpenColumnCondition(p, numRetries - 1));
            }
            else
            {
                Console.ForegroundColor = Colors.Message;
                Console.WriteLine("Column Conditions box found");
                conditions.Activate();
            }

            return(true);
        }
Example #4
0
        private void SaveReport(string path, int numberRetries = 3)
        {
            if (!EnoughRetries(numberRetries))
            {
                return;
            }

            Console.ForegroundColor = Colors.Message;
            Console.WriteLine("Saving Report to " + path);

            Input.MoveTo(new Point(15, 40));
            Thread.Sleep(100);
            Input.RegisterClick();
            Thread.Sleep(2000);

            HwndObject export = null;

            foreach (HwndObject o in HwndObject.GetWindows())
            {
                if (o.Title.Equals("Export Report"))
                {
                    export = o;
                }
            }
            if (export == null)
            {
                Console.ForegroundColor = Colors.Error;
                Console.WriteLine("Unable to find export dialog box");
                Console.WriteLine("Not enough time to find these windows. Trying once more...");
                SaveReport(path, numberRetries - 1);
                return;
            }
            else
            {
                Console.ForegroundColor = Colors.Message;
                Console.WriteLine("Export dialog box found");
                export.Activate();
            }

            Input.KeyboardWrite(path, 100);
            Input.PressKey(Input.KEY_TAB);
            Input.PressKey(Input.KEY_DOWN);
            Input.PressKey(Input.KEY_DOWN);
            Input.PressKey(Input.KEY_DOWN);
            Input.PressKey(Input.KEY_DOWN);
            Input.PressKey(Input.KEY_DOWN);
            Input.PressKey(Input.KEY_DOWN);
            Input.PressKey(Input.KEY_TAB);
            Input.PressKey(Input.KEY_ENTER);

            HwndObject confirm = null;
            Stopwatch  watch   = Stopwatch.StartNew();

            while (watch.ElapsedMilliseconds < 60000)
            {
                Console.ForegroundColor = Colors.Message;
                Console.WriteLine("Saving... (" + watch.ElapsedMilliseconds + ")");

                // Find confirmation window
                foreach (HwndObject o in HwndObject.GetWindows())
                {
                    if (o.Title.Equals("Export Report") && o.GetChildren().Count == 3)
                    {
                        confirm = o;
                        break;
                    }
                }

                if (confirm != null)
                {
                    Thread.Sleep(500);
                    confirm.Activate();
                    Input.PressKey(Input.KEY_ENTER);
                    break;
                }
                else
                {
                    Thread.Sleep(3000);
                }
            }
            watch.Stop();

            if (!File.Exists(path + ".xlsx"))
            {
                Console.ForegroundColor = Colors.Error;
                Console.WriteLine("File was not saved...trying again");
                SaveReport(path, numberRetries - 1);
            }
            else
            {
                Console.ForegroundColor = Colors.Success;
                Console.WriteLine("File was saved");
            }
        }
Example #5
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);
            }
        }