I want a code excute pluse between keys of keybaord

Nader

Well-known member
Joined
Oct 9, 2008
Messages
55
Programming Experience
Beginner
I want a code excute pluse between keys of keybaord
Key Alt + Key Shift
 
Are you saying that if the user presses Alt and Shift at the same time you want something to happen? If so then I strongly recommend against it. Alt and Shift, along with Ctrl, are called "modifier keys" for a reason. They are supposed to modify the behaviour of other keys, not do things on their own. If you wanted to do something when the user presses some other key while Shift and Alt are depressed, that would be normal. That would be done like so:
VB.NET:
Private Sub Form1_KeyDown(ByVal sender As Object, _
                          ByVal e As KeyEventArgs) Handles Me.KeyDown
    If e.KeyCode = Keys.X AndAlso _
       e.Modifiers = (Keys.Shift Or Keys.Alt) Then
        MessageBox.Show("Shift+Alt+X")
    End If
End Sub
or like so:
VB.NET:
Private Sub Form1_KeyDown(ByVal sender As Object, _
                          ByVal e As KeyEventArgs) Handles Me.KeyDown
    If e.KeyData = (Keys.X Or Keys.Shift Or Keys.Alt) Then
        MessageBox.Show("Shift+Alt+X")
    End If
End Sub
 
OKy, I want to change the position of writing in textbox by using Alt+Shift. so this will need every time press on these keys, so I want to insert tin the texbox event code that excute Alt+Shift.
 
Last edited:
I was trying this code to sendkey to solve the problem but My PC has frozen

VB.NET:
Private Sub TextBox1_KeyDown (ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown    
    System.Windows.Forms.SendKeys.Send("%+")  
  
nd Sub
</SPAN> </SPAN>
 
Right now, you're sending simple a percent sign and a plus sign, not the alt and shift keys. To send the alt and shift keys the string to send would be "{%}{+}", however I cant seem to find a need for you to need to use sendkeys at all in this case.
 
That's probably because you're using SendKeys and it's giving you un-expected results. I would suggest you re-read all 4 of your threads on this and try a different approach.
 
when I put this coede in the textbox in down event it gives me many result without stopping the project. but when I execute the code from the button click it generetd one teim, os the problem was in the textbox. How can I set this code to textbox form anohter plce like button click?
 
Back
Top