private void ExecuteQuery() { HwndObject startWindow = HwndObject.GetForegroundWindow(); Input.PressKeyCombo(Input.KEY_ALT, Input.KEY_S); Stopwatch watch = Stopwatch.StartNew(); Thread.Sleep(500); HwndObject fetching = null; foreach (HwndObject o in HwndObject.GetWindows()) { List <HwndObject> list = o.GetChildren(); if (list.Count != 3) { continue; } if (list[1].Title.Equals("Please wait...") || list[1].Title.Equals("Fetching Data...")) { Stuff.WriteConsoleMessage("Parent: " + Stuff.GetHwndInfoString(o.GetParent())); fetching = list[0]; break; } } while (HwndObject.GetForegroundWindow() != startWindow) { Console.Write("Waiting... (" + watch.ElapsedMilliseconds + ")"); if (fetching != null) { Console.WriteLine(fetching.Text); } else { Console.WriteLine(); } Thread.Sleep(5000); } watch.Stop(); Stuff.WriteConsoleSuccess("Report Generated"); }
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); } }
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"); }