55using System . Linq ;
66using System . Runtime . InteropServices ;
77using System . Windows . Forms ;
8- using System . Windows . Input ;
98using Microsoft . Vbe . Interop ;
109using Rubberduck . Common . Hotkeys ;
1110using Rubberduck . Common . WinAPI ;
1211using Rubberduck . Settings ;
1312using Rubberduck . UI . Command ;
14- using Rubberduck . UI . Command . Refactorings ;
1513using NLog ;
16- using Rubberduck . UI ;
1714
1815namespace Rubberduck . Common
1916{
2017 public class RubberduckHooks : IRubberduckHooks
2118 {
22- private readonly VBE _vbe ;
2319 private readonly IntPtr _mainWindowHandle ;
2420 private readonly IntPtr _oldWndPointer ;
2521 private readonly User32 . WndProc _oldWndProc ;
@@ -34,7 +30,6 @@ public class RubberduckHooks : IRubberduckHooks
3430
3531 public RubberduckHooks ( VBE vbe , IGeneralConfigService config , IEnumerable < CommandBase > commands )
3632 {
37- _vbe = vbe ;
3833 _mainWindowHandle = ( IntPtr ) vbe . MainWindow . HWnd ;
3934 _oldWndProc = WindowProc ;
4035 _newWndProc = WindowProc ;
@@ -175,7 +170,7 @@ public void Detach()
175170 private void hook_MessageReceived ( object sender , HookEventArgs e )
176171 {
177172 var hotkey = sender as IHotkey ;
178- if ( hotkey != null )
173+ if ( hotkey != null && hotkey . Command . CanExecute ( null ) )
179174 {
180175 hotkey . Command . Execute ( null ) ;
181176 return ;
0 commit comments