File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,11 @@ public async Task<bool> InvokeVerb(string? verb)
49
49
if ( string . IsNullOrEmpty ( verb ) )
50
50
return false ;
51
51
52
+ var item = Items . Where ( x => x . CommandString == verb ) . FirstOrDefault ( ) ;
53
+ if ( item is not null && item . ID >= 0 )
54
+ // Prefer invocation by ID
55
+ return await InvokeItem ( item . ID ) ;
56
+
52
57
try
53
58
{
54
59
var currentWindows = Win32API . GetDesktopWindows ( ) ;
@@ -73,10 +78,10 @@ public async Task<bool> InvokeVerb(string? verb)
73
78
return false ;
74
79
}
75
80
76
- public async Task InvokeItem ( int itemID )
81
+ public async Task < bool > InvokeItem ( int itemID )
77
82
{
78
83
if ( itemID < 0 )
79
- return ;
84
+ return false ;
80
85
81
86
try
82
87
{
@@ -90,13 +95,16 @@ public async Task InvokeItem(int itemID)
90
95
pici . cbSize = ( uint ) Marshal . SizeOf ( pici ) ;
91
96
92
97
await owningThread . PostMethod ( ( ) => cMenu . InvokeCommand ( pici ) ) ;
93
-
94
98
Win32API . BringToForeground ( currentWindows ) ;
99
+
100
+ return true ;
95
101
}
96
102
catch ( Exception ex ) when ( ex is COMException or UnauthorizedAccessException )
97
103
{
98
104
Debug . WriteLine ( ex ) ;
99
105
}
106
+
107
+ return false ;
100
108
}
101
109
102
110
#region FactoryMethods
You can’t perform that action at this time.
0 commit comments