473,416 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

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

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
1 9341
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: GoogleGroups | last post by:
How do I use Python to send keystrokes to a console window in Windows XP? Or perhaps there is an application that I can call to do this? Thank you for your help.
2
by: Gary | last post by:
I am trying to use the "System.Windows.Forms.SendKeys" class for triggering the Ctrl+P key. Syntax: System.Windows.Forms.SendKeys.Send("^(P)"); This is not working ..what could be the...
5
by: Go Perl | last post by:
Hello Here is an interesting question which I could not solve it. I have an old dos app for which source code is lost. I just have the exe file. So I have created a front-end for that. I...
1
by: GrantS | last post by:
I need to use a sendkeys key combination to automate the "accept files" that a remote user wants to send to me via Windows messenger. I am using automation to work with Windows Messenger client in...
6
by: Gary | last post by:
Hi, I am trying to use the "System.Windows.Forms.SendKeys" class for triggering the Ctrl+P key. Syntax: System.Windows.Forms.SendKeys.Send("^(P)") This is not working ..what could be the...
3
by: BuddyWork | last post by:
Hello, Could someone please explain why the Socket.Send is slow to send to the same process it sending from. Eg. Process1 calls Socket.Send which sends to the same IP address and port, the...
0
by: Buddy Home | last post by:
There is two examples of code. Example 1. Send and Receive within the same process. Put this code in a console app called SendAndReceive and run the code. using System; using...
0
by: neonspark | last post by:
I'm buidling some simple macro functionality for my app so the users can record a sequence of keyboard inputs and replay them reliably via some menu. Originally, I used: protected override bool...
3
by: zlf | last post by:
Hello I'm writing testcase for my console application. One testcase requires to test press Ctrl+C while the application is running. How to send Ctrl+C while running application through...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.