File tree 4 files changed +20
-1
lines changed
4 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 4
4
using System . Diagnostics ;
5
5
using SmartSystemMenu . Settings ;
6
6
using SmartSystemMenu . Native ;
7
+ using SmartSystemMenu . Utils ;
7
8
8
9
namespace SmartSystemMenu
9
10
{
@@ -46,6 +47,11 @@ public static IList<Window> EnumProcessWindows(int processId, IntPtr[] filterHan
46
47
47
48
private static bool EnumWindowCallback ( IntPtr hwnd , int lParam )
48
49
{
50
+ if ( ! WindowUtils . IsWindowVisibleOrConsole ( hwnd ) )
51
+ {
52
+ return true ;
53
+ }
54
+
49
55
if ( _filterHandles . Any ( h => h == hwnd ) )
50
56
{
51
57
return true ;
Original file line number Diff line number Diff line change @@ -299,7 +299,7 @@ private void MenuItemExitClick(object sender, EventArgs e)
299
299
300
300
private void WindowCreated ( object sender , WindowEventArgs e )
301
301
{
302
- if ( e . Handle != IntPtr . Zero && new SystemMenu ( e . Handle , _settings . MenuItems , _settings . LanguageSettings ) . Exists && ! _windows . Any ( w => w . Handle == e . Handle ) )
302
+ if ( e . Handle != IntPtr . Zero && WindowUtils . IsWindowVisibleOrConsole ( e . Handle ) && ! _windows . Any ( w => w . Handle == e . Handle ) )
303
303
{
304
304
NativeMethods . GetWindowThreadProcessId ( e . Handle , out int processId ) ;
305
305
IList < Window > windows = new List < Window > ( ) ;
Original file line number Diff line number Diff line change @@ -13,6 +13,19 @@ namespace SmartSystemMenu.Utils
13
13
{
14
14
static class WindowUtils
15
15
{
16
+ public static string GetClassName ( IntPtr hWnd )
17
+ {
18
+ var builder = new StringBuilder ( 1024 ) ;
19
+ NativeMethods . GetClassName ( hWnd , builder , builder . Capacity ) ;
20
+ var className = builder . ToString ( ) ;
21
+ return className ;
22
+ }
23
+
24
+ public static bool IsWindowVisibleOrConsole ( IntPtr hWnd )
25
+ {
26
+ return IsWindowVisible ( hWnd ) || GetClassName ( hWnd ) == "ConsoleWindowClass" ;
27
+ }
28
+
16
29
public static Bitmap PrintWindow ( IntPtr hWnd )
17
30
{
18
31
Rect rect ;
You can’t perform that action at this time.
0 commit comments