How to send a space to the console using the SendKeys class?

M

Max

Hi,

I am trying to paste text in a console window using SendKeys and the
Clipboard (I am using Windows XP SP2 and .NET 1.1). Here is the code (I
have a form with two edit boxes, DosTitle in which I type the title of
the console window (C:\WINDOWS\system32\cmd.exe) and DosKeys in which I
type the text I would like to display in the console window):

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

dosKeysText = DosKeys.Text + Chr(13)
Clipboard.SetDataObject(dosKeysText)
Try
AppActivate(DosTitle.Text)
s = "%" & " " & "ep"
SendKeys.SendWait(s)
Catch exp As ArgumentException
MessageBox.Show("AppActivate- " + exp.Message)
End Try

End Sub

The statement SendKeys.Send(s) is intended to send the sequence
ALT+SPACE+ep to the console window to paste the text in DosKeys.
Instead, the string " ep" is displayed in the console. I tried
different combinations (all suggested in various newgroups, some
claimed to be working) such as "%{SPACE}ep", "%{SPACEBAR}ep",
"%{SPC}ep", "%{space}ep", "%{ }ep", "%{}ep". The application throws an
exception saying that SPACE, SPACEBAR and SPC (first 3) are not valid
keywords or that """" and "" (last two) are not valid keywords.

Any suggestions?

Thanks!
 
T

The Grim Reaper

Have you tried s = "%( )ep" ??
The parentheses simply specify that space is to be pressed while Alt is
down, and then E and P are pressed after that.
Just thought it's one option that's not on your list!
__________________________________________
The Grim Reaper
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top