Widow – Diff between revs 11 and 12
?pathlinks?
Rev 11 | Rev 12 | |||
---|---|---|---|---|
Line 46... | Line 46... | |||
46 | }, IntPtr.Zero); |
46 | }, IntPtr.Zero); |
|
Line 47... | Line 47... | |||
47 | |
47 | |
|
48 | return windows; |
48 | return windows; |
|
Line -... | Line 49... | |||
- | 49 | } |
||
- | 50 | |
||
- | 51 | public static IEnumerable<IntPtr> EnumerateWindows() |
||
- | 52 | { |
||
- | 53 | var windows = new List<IntPtr>(); |
||
- | 54 | |
||
- | 55 | Natives.EnumWindows(delegate(IntPtr wnd, IntPtr param) |
||
- | 56 | { |
||
- | 57 | windows.Add(wnd); |
||
- | 58 | return true; |
||
- | 59 | }, IntPtr.Zero); |
||
- | 60 | |
||
- | 61 | return windows; |
||
49 | } |
62 | } |
|
50 | |
63 | |
|
51 | /// <summary> Find all windows that contain the given title text </summary> |
64 | /// <summary> Find all windows that contain the given title text </summary> |
|
52 | /// <param name="titleText"> The text that the window title must contain. </param> |
65 | /// <param name="titleText"> The text that the window title must contain. </param> |
|
53 | public static IEnumerable<IntPtr> FindWindowsWithText(string titleText) |
66 | public static IEnumerable<IntPtr> FindWindowsWithText(string titleText) |
|
Line 61... | Line 74... | |||
61 | var title = new StringBuilder(length); |
74 | var title = new StringBuilder(length); |
|
62 | Natives.GetWindowText(hWnd, title, length); |
75 | Natives.GetWindowText(hWnd, title, length); |
|
63 | return title.ToString(); |
76 | return title.ToString(); |
|
64 | } |
77 | } |
|
Line 65... | Line -... | |||
65 | |
- | ||
66 | #endregion |
- | ||
67 | |
78 | |
|
68 | public static string GetProcessName(IntPtr hWnd) |
79 | public static string GetProcessName(IntPtr hWnd) |
|
69 | { |
80 | { |
|
70 | Natives.GetWindowThreadProcessId(hWnd, out var pid); |
81 | Natives.GetWindowThreadProcessId(hWnd, out var pid); |
|
71 | var process = Process.GetProcessById((int)pid); |
82 | var process = Process.GetProcessById((int) pid); |
|
72 | return process.ProcessName; |
- | ||
73 | |
83 | return process.ProcessName; |
|
- | 84 | } |
||
- | 85 | |
||
74 | } |
86 | #endregion |
|
75 | } |
87 | } |
|
76 | } |
88 | } |