[HELP] How do you make SendKeys work?

Posts 1–5 of 5 · Page 1 of 1
[HELP] How do you make SendKeys work?
I'm personally making a On-Screen Number Pad right now for users who use laptops. And when I debugged it, and tried it, it doesn't work! So I'm guessing I need to have a target process or something. But I don't know how! Help! Here's my code:

[PHP]Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim TargetProcess As Process() = Process.GetProcessesByName(TextBox1.Text)

End Sub
End Class[/PHP]

That's the TargetProcess. Here's the Number Pad:

[PHP]Public Class Form2

Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click

End

End Sub

Private Sub AlwaysOnTopToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AlwaysOnTopToolStripMenuItem.Click

If AlwaysOnTopToolStripMenuItem.Checked = True Then

Me.TopMost = True

Else

Me.TopMost = False

End If

End Sub

Private Sub Button0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button0.Click

SendKeys.SendWait(Keys.NumPad0)

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

SendKeys.SendWait(Keys.NumPad1)

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

SendKeys.SendWait(Keys.NumPad2)

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

SendKeys.SendWait(Keys.NumPad3)

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

SendKeys.SendWait(Keys.NumPad4)

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

SendKeys.SendWait(Keys.NumPad5)

End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

SendKeys.SendWait(Keys.NumPad6)

End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

SendKeys.SendWait(Keys.NumPad7)

End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click

SendKeys.SendWait(Keys.NumPad8)

End Sub

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click

SendKeys.SendWait(Keys.NumPad9)

End Sub

Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click

SendKeys.SendWait(Keys.Divide)

End Sub

Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click

SendKeys.SendWait(Keys.Multiply)

End Sub

Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click

SendKeys.SendWait(Keys.Decimal)

End Sub

Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click

SendKeys.SendWait(Keys.Enter)

End Sub

Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click

SendKeys.SendWait(Keys.Add)

End Sub

Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click

SendKeys.SendWait(Keys.Subtract)

End Sub
End Class[/PHP]

Help!
If you want to send a message/key to a process without having it focused, go for SendMessage.
Quote Originally Posted by Blubb1337 View Post
If you want to send a message/key to a process without having it focused, go for SendMessage.
What do you mean SendMessage? I can't find it.
Quote Originally Posted by Gasps Its Michael Jackson View Post


What do you mean SendMessage? I can't find it.
what about searching on MSDN? If it exists.. it will be there...

SendMessage
You need to use P/Invoke

Code:
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function SendMessage(ByVal Handle As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
End Function
If that doesn't work

Code:
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
End Function
Posts 1–5 of 5 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us