468,537 Members | 2,337 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,537 developers. It's quick & easy.

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!

Jun 13 '06 #1
3 5381
Have a look at:

SendKeys.Send
SendKeys.SendWait

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" <Su*******@gmail.com> schreef in bericht
news:11**********************@h76g2000cwa.googlegr oups.com...
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!

Jun 13 '06 #2
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:
Have a look at:

SendKeys.Send
SendKeys.SendWait

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" <Su*******@gmail.com> schreef in bericht
news:11**********************@h76g2000cwa.googlegr oups.com...
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!


Jun 13 '06 #3
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.WriteLine("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.WriteLine("Hello I'm waiting for text in c:\test.txt")
Do While checkFile() = False
Threading.Thread.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(myReader)
strMessage = myStreamReader.ReadToEnd()
myStreamReader.Close()
myReader.Close()
If strMessage = "" Then
Return False
Else
Console.WriteLine(strMessage)
Console.ReadLine()
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" <Su*******@gmail.com> schreef in bericht
news:11**********************@c74g2000cwc.googlegr oups.com...
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:
Have a look at:

SendKeys.Send
SendKeys.SendWait

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" <Su*******@gmail.com> schreef in bericht
news:11**********************@h76g2000cwa.googlegr oups.com...
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!

Jun 14 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by magician | last post: by
4 posts views Thread by Ralf Toender | last post: by
reply views Thread by CForrester | last post: by
1 post views Thread by Jacek Jurkowski | last post: by
5 posts views Thread by mattmao | last post: by
11 posts views Thread by vbguy2008 | last post: by
8 posts views Thread by Ron Eggler | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.