Reputation: 11
I have a DataGridView
with a context menu. One menu item is Copy (with a Ctrl+C hotkey.) All I want to do is either get the current mouse location to copy the cell that the user right-clicked, or get the currently selected cell if they used the hot-key. In both cases the menu_Click
event gets fired. How can I tell if it was from a hotkey or the context menu?
Upvotes: 0
Views: 125
Reputation: 16698
To best of my knowledge you can Hook
all the Mouse
and Keyboard
events to detect the source of input.
You should have a look at this CodeProject article, Processing Global Mouse and Keyboard Hooks in C#
A global hook monitors messages for all threads in the same desktop as the calling thread. A thread-specific hook monitors messages for only an individual thread. A global hook procedure can be called in the context of any application in the same desktop as the calling thread, so the procedure must be in a separate DLL module. A thread-specific hook procedure is called only in the context of the associated thread.
Upvotes: 1