Guest User

Untitled

a guest
May 24th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. namespace FEWindowSelectionFrameTest
  2. {
  3. public partial class MainWindow : System.Windows.Window
  4. {
  5. [System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
  6. static extern int GetWindowTextLength(System.IntPtr hWnd);
  7. [System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]
  8. static extern int GetWindowText(System.IntPtr hWnd, System.Text.StringBuilder lpString, int nMaxCount);
  9.  
  10. FreeEcho.FEWindowSelectionFrame.WindowSelectionFrame f_window_selection_frame = null;
  11.  
  12. public MainWindow()
  13. {
  14. try
  15. {
  16. InitializeComponent();
  17.  
  18. button_window_selection.PreviewMouseDown += Button_window_selection_PreviewMouseDown;
  19. button_window_selection.PreviewMouseUp += Button_window_selection_PreviewMouseUp;
  20. }
  21. catch
  22. {
  23. }
  24. }
  25.  
  26. private void Button_window_selection_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
  27. {
  28. try
  29. {
  30. f_window_selection_frame = new FreeEcho.FEWindowSelectionFrame.WindowSelectionFrame();
  31. f_window_selection_frame.StartWindowSelection();
  32. }
  33. catch
  34. {
  35. }
  36. }
  37.  
  38. private void Button_window_selection_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
  39. {
  40. try
  41. {
  42. f_window_selection_frame.StopWindowSelection();
  43.  
  44. System.Text.StringBuilder string_data = new System.Text.StringBuilder(GetWindowTextLength(f_window_selection_frame.SelectionHwnd) + 1);
  45. GetWindowText(f_window_selection_frame.SelectionHwnd, string_data, string_data.Capacity);
  46. System.Diagnostics.Debug.WriteLine(string_data.ToString());
  47. }
  48. catch
  49. {
  50. }
  51. }
  52. }
  53. }
Add Comment
Please, Sign In to add comment