By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,885 Members | 1,469 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,885 IT Pros & Developers. It's quick & easy.

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

P: n/a
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!

Nov 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

"Max" <mi****@yahoo.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
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!

Nov 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.