Closed yongzhi444 closed 4 years ago
Hi there, sorry for my late reply.
To block a single or a combination of keystrokes simply set e.Block = True
in the hook event handler when the input satisfies your needs.
Private Sub KeyboardHook_KeyDown(sender As System.Object, e As InputHelper.EventArgs.KeyboardHookEventArgs) Handles KeyboardHook.KeyDown
If e.Modifiers = InputHelper.ModifierKeys.Control AndAlso e.KeyCode = Keys.C Then
e.Block = True 'Prevents CTRL + C from reaching any other applications or from executing standard Windows actions.
End If
End Sub
Note that this will block all use of CTRL + C which, in some cases, are used for other shortcuts than just "copy". For instance in CMD it is used to terminate the currently running command/script.
Please take a look at Event Args on the Wiki, if you haven't already, to get an overview of what information is made available through the event.
Hope this helped!
thanks a lot!
example, i hook the keydown, if "ctrl + c" is pressed, i want to stop "copy" action. how i do? thanks a lot!