Emulating keyboard strokes in vb.net

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paulers

    #1

    Emulating keyboard strokes in vb.net

    Hello,

    I need to emulate keyboard strokes from a console application. The
    console application monitors a textfile and when something is matched
    in a text file I need the matched string outputted to the keyboard as
    if someone was typing on the keyboard. can someone help me locate the
    correct vb.net function to use?

    Thanks!

  • Peter Proost

    #2
    Re: Emulating keyboard strokes in vb.net

    Have a look at:

    SendKeys.Send
    SendKeys.SendWa it

    They do what you want.

    Greetz Peter

    --
    Programming today is a race between software engineers striving to build
    bigger and better idiot-proof programs, and the Universe trying to produce
    bigger and better idiots. So far, the Universe is winning. (Rich Cook)

    "Paulers" <SuperGh0d@gmai l.com> schreef in bericht
    news:1150171895 .121750.311990@ h76g2000cwa.goo glegroups.com.. .[color=blue]
    > Hello,
    >
    > I need to emulate keyboard strokes from a console application. The
    > console application monitors a textfile and when something is matched
    > in a text file I need the matched string outputted to the keyboard as
    > if someone was typing on the keyboard. can someone help me locate the
    > correct vb.net function to use?
    >
    > Thanks!
    >[/color]


    Comment

    • Paulers

      #3
      Re: Emulating keyboard strokes in vb.net

      Thanks for the response but can I use those functions from a console
      application? Or does it have to be a form applicaton?

      Peter Proost wrote:[color=blue]
      > Have a look at:
      >
      > SendKeys.Send
      > SendKeys.SendWa it
      >
      > They do what you want.
      >
      > Greetz Peter
      >
      > --
      > Programming today is a race between software engineers striving to build
      > bigger and better idiot-proof programs, and the Universe trying to produce
      > bigger and better idiots. So far, the Universe is winning. (Rich Cook)
      >
      > "Paulers" <SuperGh0d@gmai l.com> schreef in bericht
      > news:1150171895 .121750.311990@ h76g2000cwa.goo glegroups.com.. .[color=green]
      > > Hello,
      > >
      > > I need to emulate keyboard strokes from a console application. The
      > > console application monitors a textfile and when something is matched
      > > in a text file I need the matched string outputted to the keyboard as
      > > if someone was typing on the keyboard. can someone help me locate the
      > > correct vb.net function to use?
      > >
      > > Thanks!
      > >[/color][/color]

      Comment

      • Peter Proost

        #4
        Re: Emulating keyboard strokes in vb.net

        I'm sorry sendkeys indeed can't be used with a console app, I read your OP
        to quick.
        But can't you use Console.WriteLi ne("The matched part")
        Something like this quick sample I made, it just keeps checking c:\test.txt
        until it finds some text in it and the outputs it to the console if the text
        is found

        Sub Main()
        Console.WriteLi ne("Hello I'm waiting for text in c:\test.txt")
        Do While checkFile() = False
        Threading.Threa d.CurrentThread .Sleep(1000)
        Loop
        End Sub

        Private Function checkFile() As Boolean
        Dim strMessage As String
        Dim myReader As New FileStream("c:\ test.txt", FileMode.Open,
        FileAccess.Read )
        Dim myStreamReader As New StreamReader(my Reader)
        strMessage = myStreamReader. ReadToEnd()
        myStreamReader. Close()
        myReader.Close( )
        If strMessage = "" Then
        Return False
        Else
        Console.WriteLi ne(strMessage)
        Console.ReadLin e()
        Return True
        End If


        End Function


        Hope this helps,

        Greetz Peter

        --
        Programming today is a race between software engineers striving to build
        bigger and better idiot-proof programs, and the Universe trying to produce
        bigger and better idiots. So far, the Universe is winning. (Rich Cook)

        "Paulers" <SuperGh0d@gmai l.com> schreef in bericht
        news:1150226335 .224424.229970@ c74g2000cwc.goo glegroups.com.. .[color=blue]
        > Thanks for the response but can I use those functions from a console
        > application? Or does it have to be a form applicaton?
        >
        > Peter Proost wrote:[color=green]
        > > Have a look at:
        > >
        > > SendKeys.Send
        > > SendKeys.SendWa it
        > >
        > > They do what you want.
        > >
        > > Greetz Peter
        > >
        > > --
        > > Programming today is a race between software engineers striving to build
        > > bigger and better idiot-proof programs, and the Universe trying to[/color][/color]
        produce[color=blue][color=green]
        > > bigger and better idiots. So far, the Universe is winning. (Rich Cook)
        > >
        > > "Paulers" <SuperGh0d@gmai l.com> schreef in bericht
        > > news:1150171895 .121750.311990@ h76g2000cwa.goo glegroups.com.. .[color=darkred]
        > > > Hello,
        > > >
        > > > I need to emulate keyboard strokes from a console application. The
        > > > console application monitors a textfile and when something is matched
        > > > in a text file I need the matched string outputted to the keyboard as
        > > > if someone was typing on the keyboard. can someone help me locate the
        > > > correct vb.net function to use?
        > > >
        > > > Thanks!
        > > >[/color][/color]
        >[/color]


        Comment

        Working...