private void btnAutomationChooseWindow_Click(object sender, RoutedEventArgs e) { if (_automationChosenProc == null) { Utilities.Message("Please choose process first."); return; } //Structs.WindowInfo windowInfo; var allWindowHandles = Managed.GetAllWindows(_automationChosenProc.Process) .OfType<IntPtr>() .Distinct(); //.Where(item => ((windowInfo = Managed.GetWindowInfo(item)).dwStyle.HasFlag(Enums.WindowStyles.WS_CAPTION) && // windowInfo.dwStyle.HasFlag(Enums.WindowStyles.WS_VISIBLE)) || // windowInfo.dwExStyle.HasFlag(Enums.WindowStylesEx.WS_EX_APPWINDOW)).ToList(); string title = null; string className = null; Structs.WindowInfo windowInfo; var allWindowHandlesDictionary = allWindowHandles .ToDictionary( item => (int)item, item => ( (!string.IsNullOrWhiteSpace((title = Managed.GetWindowText(item))) ? title : string.Empty) + ";" + (!string.IsNullOrWhiteSpace(className = Managed.GetClassName(item)) ? "ClassName: " + className : string.Empty) + ";Visible: " + ((windowInfo = Managed.GetWindowInfo(item)).dwStyle.HasFlag(Enums.WindowStyles.WS_CAPTION) ? "True" : "False") ) ); var chooseWindow = new ItemChoose((windowHandle) => { var ptrWindowHandle = (IntPtr)windowHandle; _automationChosenWindow = new ProcessWindow(_automationChosenProc.Id, ptrWindowHandle, Managed.GetWindowText(ptrWindowHandle)); var content = string.Concat("WindowHandle: " + windowHandle, " Name: " + _automationChosenWindow.Title); lblAutomationChosenWindow.Content = content; }, allWindowHandlesDictionary, isOrderByKey: false, onCancel: () => { _automationChosenWindow = null; lblAutomationChosenWindow.Content = "No Window Chosen"; }); chooseWindow.ShowDialog(); }
private void ChooseProcess_Click(object sender, RoutedEventArgs e) { var chooseProcess = new ItemChoose((processID) => { _memoryWalkerChosenProc = new Proc(Process.GetProcessById(processID)); var content = string.Concat("Chosen Process: ", _memoryWalkerChosenProc.Id); lblMemoryWalkerChosenProcess.Content = content; }, Proc.GetAllProcesses(false).ToDictionary(item => item.Id, item => item.Name), isOrderByKey: false); chooseProcess.ShowDialog(); }
private void btnAutomationChooseProcess_Click(object sender, RoutedEventArgs e) { _automationChosenWindow = null; lblAutomationChosenWindow.Content = "No Window Chosen"; var chooseProcess = new ItemChoose((processID) => { _automationChosenProc = new Proc(Process.GetProcessById(processID)); var content = string.Concat("PID: " + _automationChosenProc.Id, " Name: " + _automationChosenProc.Name); lblAutomationChosenProcess.Content = content; }, Proc.GetAllProcesses(false).ToDictionary(item => item.Id, item => item.Name), isOrderByKey: false, onCancel: () => { _automationChosenProc = null; lblAutomationChosenProcess.Content = "No Process Chosen"; }); chooseProcess.ShowDialog(); }