private async Task CreateNewTest() { Process process = await AppTest.StartAsync("notepad", 1000); while (true) { Console.WriteLine("MainWindow: " + process.MainWindowHandle); var top = User32.GetTopWindow(process.MainWindowHandle); Console.WriteLine("Top window: " + top); /*User32.EnumWindows((ptr,arg) => * { * int pId; * User32.GetWindowThreadProcessId(ptr, out pId); * if (pId == process.Id) * { * StringBuilder bld = new StringBuilder(200); * User32.GetWindowText(ptr, bld, 200); * Console.WriteLine($"{ptr} - {bld} - {User32.IsWindowEnabled(ptr)}"); * } * return true; * }, IntPtr.Zero);*/ foreach (var ptr in User32.EnumerateProcessWindowHandles(process.Id)) { StringBuilder bld = new StringBuilder(200); User32.GetWindowText(process.MainWindowHandle, bld, 200); if (User32.IsWindowVisible(ptr)) { Console.WriteLine($"{ptr} - {bld} - {User32.IsWindowEnabled(ptr)} - {User32.IsWindowVisible(ptr)} - {User32.GetWindowLongA(ptr, -16)& 0x00C00000}"); } } Console.WriteLine(); await Task.Delay(1000); } return; HwndSourceParameters parameters = new HwndSourceParameters(); parameters.WindowStyle = (int)(WindowStyles.WS_CHILD | WindowStyles.WS_CLIPCHILDREN | WindowStyles.WS_CLIPSIBLINGS | WindowStyles.WS_VISIBLE); parameters.ParentWindow = process.MainWindowHandle; Overlay frameworkElement = new Overlay(); HwndSource hwndSource = new HwndSource(parameters) { SizeToContent = SizeToContent.WidthAndHeight, RootVisual = frameworkElement }; hwndSource.CompositionTarget.BackgroundColor = Colors.LightSteelBlue; // black background seems too dominant, use a different default frameworkElement.Width = 500; frameworkElement.Height = 500; }
private static void RunExisting() { Model model = new Model { Program = "notepad", Actions = { new MouseClickAction { X = 10, Y = 0 } } }; AppTest.Run(model, interactive: true); }