Hay habe folgendes problem:
Ich habe ein Programm gemacht für ein Spiel. Das Programm soll halt immer wenn man "Z" drückt, F1 - F9 durchdrücken. Doch wenn ich jetz zu dem Spiel wechsle und "Z" drücke passiert nix.
[Ps: Ein bissl umständlich gecodet]
Ich habe ein Programm gemacht für ein Spiel. Das Programm soll halt immer wenn man "Z" drückt, F1 - F9 durchdrücken. Doch wenn ich jetz zu dem Spiel wechsle und "Z" drücke passiert nix.
[Ps: Ein bissl umständlich gecodet]
VB.NET-Quellcode
- Public Class Form1
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Me.KeyPreview = True
- End Sub
- Private Sub Form1_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
- If e.KeyCode = Keys.Z Then
- Button1.PerformClick()
- ElseIf e.KeyCode = Keys.Q Then
- Button2.PerformClick()
- End If
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- If ComboBox1.Text = "F - Leiste 1" Then
- SendKeys.Send(Keys.D1)
- SendKeys.Send(Keys.F1)
- SendKeys.Send(Keys.F2)
- SendKeys.Send(Keys.F3)
- SendKeys.Send(Keys.F4)
- SendKeys.Send(Keys.F5)
- SendKeys.Send(Keys.F6)
- SendKeys.Send(Keys.F7)
- SendKeys.Send(Keys.F8)
- SendKeys.Send(Keys.F9)
- ElseIf ComboBox1.Text = "F - Leiste 2" Then
- SendKeys.Send(Keys.D2)
- SendKeys.Send(Keys.F1)
- SendKeys.Send(Keys.F2)
- SendKeys.Send(Keys.F3)
- SendKeys.Send(Keys.F4)
- SendKeys.Send(Keys.F5)
- SendKeys.Send(Keys.F6)
- SendKeys.Send(Keys.F7)
- SendKeys.Send(Keys.F8)
- SendKeys.Send(Keys.F9)
- ElseIf ComboBox1.Text = "F - Leiste 3" Then
- SendKeys.Send(Keys.D3)
- SendKeys.Send(Keys.F1)
- SendKeys.Send(Keys.F2)
- SendKeys.Send(Keys.F3)
- SendKeys.Send(Keys.F4)
- SendKeys.Send(Keys.F5)
- SendKeys.Send(Keys.F6)
- SendKeys.Send(Keys.F7)
- SendKeys.Send(Keys.F8)
- SendKeys.Send(Keys.F9)
- ElseIf ComboBox1.Text = "F - Leiste 4" Then
- SendKeys.Send(Keys.D4)
- SendKeys.Send(Keys.F1)
- SendKeys.Send(Keys.F2)
- SendKeys.Send(Keys.F3)
- SendKeys.Send(Keys.F4)
- SendKeys.Send(Keys.F5)
- SendKeys.Send(Keys.F6)
- SendKeys.Send(Keys.F7)
- SendKeys.Send(Keys.F8)
- SendKeys.Send(Keys.F9)
- ElseIf ComboBox1.Text = "F - Leiste 5" Then
- SendKeys.Send(Keys.D5)
- SendKeys.Send(Keys.F1)
- SendKeys.Send(Keys.F2)
- SendKeys.Send(Keys.F3)
- SendKeys.Send(Keys.F4)
- SendKeys.Send(Keys.F5)
- SendKeys.Send(Keys.F6)
- SendKeys.Send(Keys.F7)
- SendKeys.Send(Keys.F8)
- SendKeys.Send(Keys.F9)
- ElseIf ComboBox1.Text = "F - Leiste 6" Then
- SendKeys.Send(Keys.D6)
- SendKeys.Send(Keys.F1)
- SendKeys.Send(Keys.F2)
- SendKeys.Send(Keys.F3)
- SendKeys.Send(Keys.F4)
- SendKeys.Send(Keys.F5)
- SendKeys.Send(Keys.F6)
- SendKeys.Send(Keys.F7)
- SendKeys.Send(Keys.F8)
- SendKeys.Send(Keys.F9)
- ElseIf ComboBox1.Text = "F - Leiste 7" Then
- SendKeys.Send(Keys.D7)
- SendKeys.Send(Keys.F1)
- SendKeys.Send(Keys.F2)
- SendKeys.Send(Keys.F3)
- SendKeys.Send(Keys.F4)
- SendKeys.Send(Keys.F5)
- SendKeys.Send(Keys.F6)
- SendKeys.Send(Keys.F7)
- SendKeys.Send(Keys.F8)
- SendKeys.Send(Keys.F9)
- ElseIf ComboBox1.Text = "F - Leiste 8" Then
- SendKeys.Send(Keys.D8)
- SendKeys.Send(Keys.F1)
- SendKeys.Send(Keys.F2)
- SendKeys.Send(Keys.F3)
- SendKeys.Send(Keys.F4)
- SendKeys.Send(Keys.F5)
- SendKeys.Send(Keys.F6)
- SendKeys.Send(Keys.F7)
- SendKeys.Send(Keys.F8)
- SendKeys.Send(Keys.F9)
- ElseIf ComboBox1.Text = "F - Leiste 9" Then
- SendKeys.Send(Keys.D9)
- SendKeys.Send(Keys.F1)
- SendKeys.Send(Keys.F2)
- SendKeys.Send(Keys.F3)
- SendKeys.Send(Keys.F4)
- SendKeys.Send(Keys.F5)
- SendKeys.Send(Keys.F6)
- SendKeys.Send(Keys.F7)
- SendKeys.Send(Keys.F8)
- SendKeys.Send(Keys.F9)
- End If
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- If ComboBox2.Text = "F - Leiste 1" Then
- SendKeys.Send(Keys.D1)
- SendKeys.Send(Keys.F1)
- SendKeys.Send(Keys.F2)
- SendKeys.Send(Keys.F3)
- SendKeys.Send(Keys.F4)
- SendKeys.Send(Keys.F5)
- SendKeys.Send(Keys.F6)
- SendKeys.Send(Keys.F7)
- SendKeys.Send(Keys.F8)
- SendKeys.Send(Keys.F9)
- ElseIf ComboBox2.Text = "F - Leiste 2" Then
- SendKeys.Send(Keys.D2)
- SendKeys.Send(Keys.F1)
- SendKeys.Send(Keys.F2)
- SendKeys.Send(Keys.F3)
- SendKeys.Send(Keys.F4)
- SendKeys.Send(Keys.F5)
- SendKeys.Send(Keys.F6)
- SendKeys.Send(Keys.F7)
- SendKeys.Send(Keys.F8)
- SendKeys.Send(Keys.F9)
- ElseIf ComboBox2.Text = "F - Leiste 3" Then
- SendKeys.Send(Keys.D3)
- SendKeys.Send(Keys.F1)
- SendKeys.Send(Keys.F2)
- SendKeys.Send(Keys.F3)
- SendKeys.Send(Keys.F4)
- SendKeys.Send(Keys.F5)
- SendKeys.Send(Keys.F6)
- SendKeys.Send(Keys.F7)
- SendKeys.Send(Keys.F8)
- SendKeys.Send(Keys.F9)
- ElseIf ComboBox2.Text = "F - Leiste 4" Then
- SendKeys.Send(Keys.D4)
- SendKeys.Send(Keys.F1)
- SendKeys.Send(Keys.F2)
- SendKeys.Send(Keys.F3)
- SendKeys.Send(Keys.F4)
- SendKeys.Send(Keys.F5)
- SendKeys.Send(Keys.F6)
- SendKeys.Send(Keys.F7)
- SendKeys.Send(Keys.F8)
- SendKeys.Send(Keys.F9)
- ElseIf ComboBox2.Text = "F - Leiste 5" Then
- SendKeys.Send(Keys.D5)
- SendKeys.Send(Keys.F1)
- SendKeys.Send(Keys.F2)
- SendKeys.Send(Keys.F3)
- SendKeys.Send(Keys.F4)
- SendKeys.Send(Keys.F5)
- SendKeys.Send(Keys.F6)
- SendKeys.Send(Keys.F7)
- SendKeys.Send(Keys.F8)
- SendKeys.Send(Keys.F9)
- ElseIf ComboBox2.Text = "F - Leiste 6" Then
- SendKeys.Send(Keys.D6)
- SendKeys.Send(Keys.F1)
- SendKeys.Send(Keys.F2)
- SendKeys.Send(Keys.F3)
- SendKeys.Send(Keys.F4)
- SendKeys.Send(Keys.F5)
- SendKeys.Send(Keys.F6)
- SendKeys.Send(Keys.F7)
- SendKeys.Send(Keys.F8)
- SendKeys.Send(Keys.F9)
- ElseIf ComboBox2.Text = "F - Leiste 7" Then
- SendKeys.Send(Keys.D7)
- SendKeys.Send(Keys.F1)
- SendKeys.Send(Keys.F2)
- SendKeys.Send(Keys.F3)
- SendKeys.Send(Keys.F4)
- SendKeys.Send(Keys.F5)
- SendKeys.Send(Keys.F6)
- SendKeys.Send(Keys.F7)
- SendKeys.Send(Keys.F8)
- SendKeys.Send(Keys.F9)
- ElseIf ComboBox2.Text = "F - Leiste 8" Then
- SendKeys.Send(Keys.D8)
- SendKeys.Send(Keys.F1)
- SendKeys.Send(Keys.F2)
- SendKeys.Send(Keys.F3)
- SendKeys.Send(Keys.F4)
- SendKeys.Send(Keys.F5)
- SendKeys.Send(Keys.F6)
- SendKeys.Send(Keys.F7)
- SendKeys.Send(Keys.F8)
- SendKeys.Send(Keys.F9)
- ElseIf ComboBox2.Text = "F - Leiste 9" Then
- SendKeys.Send(Keys.D9)
- SendKeys.Send(Keys.F1)
- SendKeys.Send(Keys.F2)
- SendKeys.Send(Keys.F3)
- SendKeys.Send(Keys.F4)
- SendKeys.Send(Keys.F5)
- SendKeys.Send(Keys.F6)
- SendKeys.Send(Keys.F7)
- SendKeys.Send(Keys.F8)
- SendKeys.Send(Keys.F9)
- End If
- End Sub
- End Class