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!
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!