This article will show you how you can detect the button
combination pressed in windows
application using c#.net in windows
application. Here I will show an example of detecting or capturing ctrl+v
button in windows
application.
Some of my previous articles are as follows: Group
CheckBox In C# WinForm, Read
Outlook Email Subject Using c#, Read
Outlook Inbox Mail And Email Count Of Inbox Using C#.Net, How
To Read XML File In DataSet And Display in DataGridview Using C#.Net,
WebBrowser
Control in C#, Windows Application,
Change
Control Font Size At Runtime / Dynamically Using C#.Net and VB.Net In Windows
Application, Change
Control Font Size At Runtime / Dynamically Using C#.Net and VB.Net In Windows
Application, Windows
Application In C#.Net (My first video article on youtube.com), How
to Create a Code 128 Barcode Label Using windows Font in C# ,Windows
Application, How
To Get Enumerate Installed Fonts List In Your Computer Using C# Windows
Application , Blinking
Text in C#.Net Windows Application.
C#.Net
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control && e.KeyCode
== Keys.V)
{
label1.Text = "You have pressed
Ctrl+V";
}
}
|
VB.Net
Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs)
If e.Control AndAlso e.KeyCode = Keys.V
Then
label1.Text = "You have pressed
Ctrl+V"
End If
End Sub
|
Here in above code e.Control is for Ctrl Button and Keys.V
for V button. So I have display the message as user press the specified button combination.
Now we have done run the application to check the output.
How to detect control+v even outside app
ReplyDeleteHi Natesh,
DeleteWhat do you mean by even outside app. Please explain it more.
Thanks
This will work when the form is maximised. you minimise it and press control+ v in notepad to paste something, this won't work
DeleteThis will work when the form is maximised. you minimise it and press control+ v in notepad to paste something, this won't work
DeleteHi Gokul,
DeleteI got your point i will check and get back to you.