VSTO 覆盖自定义任务窗格中的 Excel 个热键

VSTO override Excel hotkeys inside custom task pane

是否可以在自定义任务窗格中覆盖 Excel 键盘快捷键?

例如,我想捕获快捷方式 Ctrl+Space,但是 Excel 已经在使用该快捷方式在自定义任务窗格中,并且该快捷方式永远不会到达我的用户控件上的 KeyPressed 事件处理程序。

Excel 不使用的其他组合键可以很好地到达我的事件处理程序。

有没有办法覆盖它,也许通过 Windows API?

您可以使用 SetWindowsHookEx function from Windows API to set up a keyboard hook. But overriding the built-in keyboard shortcut is not a good idea. Anyway, you can read more about this and find a sample code in the Using shortcut keys to call a function in an Office Add-in 文章。