Hi All on Daniweb.. I am starting a little project that needs hardware and software.. I decided to first start with the software and thats where Im having some trouble right now.. I can easily make a virtual keyboard that runs in vb.net but what i want it to do ideally is run on other programs such as typing in internet explorer or word.. I would like it to be like the on screen keyboard that windows has.. Does anyone know of anyways that this is possible in vb.net?? As of right now im using a richtextbox and I have buttons as the keys.. When you press the button it essentially does richtextbox1.text = Richtextbox1.text + (the key) .. Thanks for your help..

Thank you for the help and sending me in the right direction but I am still having problems.. What I need to do is identify the parent window class name.. I can do this but it only comes up in a msgbox.. I used
SendKeys.Sleep(3000)
Dim w As New SendKeys.WINFOCUS
w = SendKeys.GetWinFocus(True, True)
TextBox1.Text = w.Focus.ToString .
I textbox1.text does not come up as the parent name but it comes up as a bunch of numbers.. For example for notepad it comes up as 657344. Any ideas?? I know the numbers are identifiers for something but I do not really know how to use them to add text.. With the parent name I could use
Dim w As New SendKeys.WINFOCUS
w = SendKeys.GetWinHandles(parentname, 1, "Edit", 1)
SendKeys.Send("q", w)

Or
Dim w As New SendKeys.WINFOCUS
w = SendKeys.GetWinHandles(process ID, 1, "Edit", 1)
SendKeys.Send("q", w) .. but the process ID doesnt work like this..

Phew.. Okay so I got it to work like this..
SendKeys.Sleep(2000)
SendKeys.Send("q", Nothing) ... Now my only problem is I have to click on where I want to type everytime.. Is there anyway to reverse this process or keep my vb.net program from gaining focus ever?? Thanks for your help

you can create an ActiveX using the same and register it in your computer with Rgserver.
then same on other computers with vb drag this control on form after referencing it in Project _references

Comments
Your post didn't help us. OP uses VB.NET and he/she wants to get solution using .net framework not with a DNA framework.

Thank you all for the help.. I got my onscreenkeyboard up and running.. Took alot of time and effort but it works! For the most part.. My last problem is I cannot get the enter button and backspace button to work..
Im using Sendkeys.send("{Enter}", Nothing) and its coming up as Enter when I press it.. Any ideas?? And again.. Thanks all for the help..

Hey sknake.. Thanks for your help but unfortunately "{ENTER}" yielded the same results..
SendKeys.Sleep(6)
AppActivate(TextBox1.Text)
SendKeys.Send("{ENTER}", Nothing)

I also use
SendKeys.Sleep(6)
AppActivate(TextBox1.Text)
SendKeys.Send("{BACKSPACE}", Nothing)
and this also comes up as "backspace" and not deleting the characters.. Any ideas what im doing wrong??
I appreciate the help.. Thank you

Can you upload your project so I can take a look at it? Where are you getting SendKeys.Sleep() ? Are you exporting win32 calls?

I would prefer not to send my project because I did not reference and I did not comment =/ .. I should probably do that.. But ill show you the best I can whats going on.. So what I have is a form with a keyboard layout as buttons.. I then also have a timer that grabs the active windows Title..

Private Declare Function GetForegroundWindow Lib "user32.dll" () As IntPtr
    Private Declare Function GetWindowThreadProcessId Lib "user32.dll" (ByVal hwnd As IntPtr, ByRef lpdwProcessID As Integer) As Integer
    Private Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hWnd As IntPtr, ByVal WinTitle As String, ByVal MaxLength As Integer) As Integer
    Private Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Integer
    'From http://kellychronicles.spaces.live.com/blog/cns!A0D71E1614E8DBF8!161.entry

    '----- Get the Handle to the Current Forground Window -----


    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim hWnd As IntPtr = GetForegroundWindow()
        Dim Before As String
        Before = TextBox1.Text
        If hWnd = IntPtr.Zero Then Exit Sub

        '----- Find the Length of the Window's Title -----

        Dim TitleLength As Integer

        TitleLength = GetWindowTextLength(hWnd)

        '----- Find the Window's Title -----

        Dim WindowTitle As String = StrDup(TitleLength + 1, "*")

        GetWindowText(hWnd, WindowTitle, TitleLength + 1)

        '----- Find the PID of the Application that Owns the Window -----

        Dim pid As Integer = 0

        GetWindowThreadProcessId(hWnd, pid)

        If pid = 0 Then Exit Sub

        '----- Get the actual PROCESS from the process ID -----

        Dim proc As Process = Process.GetProcessById(pid)

        If proc Is Nothing Then Exit Sub

        TextBox1.Text = proc.MainWindowTitle

        Dim Hello As String
        Hello = Trim(TextBox1.Text)
        If Hello = "Form1" Then
            TextBox1.Text = Before
        End If
        If Hello <> "Form1" Then
            TextBox1.Text = Hello
        End If
    End Sub

And then for every button on keyboard layout I have

SendKeys.Sleep(6)
            AppActivate(TextBox1.Text)
            SendKeys.Send("{ENTER}", Nothing)

Nope.. That didn't work either.. Still outputs \n and \b.. I am flabbergasted.. It could be just the nature of the way I wrote the program??

I got the sleep function from some other program I didnt write.

Public Function Sleep(Optional ByVal dwMilliseconds As Int32 = 0, Optional ByVal fInterval As Int32 = 1) As Boolean
        Dim tick As Int32 = System.Environment.TickCount 'Get the number of millisecons since last log on
        If fInterval > 4999 Then fInterval = 4999 ''''Make sure interval is not longer than 5 seconds to avoid hanging the main app window
        Do '''''''''''''''''''''''''''''''''''''''''''Loop until the specified timeout
            System.Threading.Thread.Sleep(fInterval) 'Sleep for one interval at a time
            apiSwitchToThread() : Flush() ''''''''''''Yield to other waiting threads of the OS's choice.  Process any messages in the queue
            If dwMilliseconds = 0 Then '''''''''''''''If short rest specified
                If apiGetQueueStatus(QS_ALLQUEUE) = 0 OrElse System.Environment.TickCount >= (tick + 5000) Then Return True 'If there are no key/mouse messages in the queue or 5 seconds has elapsed then return
            Else '''''''''''''''''''''''''''''''''''''If a timeout is specified
                If System.Environment.TickCount >= (tick + dwMilliseconds) Then Return Not CBool(apiGetQueueStatus(QS_ALLQUEUE)) 'If time is up then exit with return of state
            End If
        Loop
    End Function
This question has already been answered. Start a new discussion instead.