Jump to content
  • Advertisement
Sign in to follow this  
SelethD

? represent 'backspace' in c# string

This topic is 3302 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello Im making a program that will auto fill forms. I am using the SendKeys.Send(string) function to send the text to the active application. However, my problem is that some forms have default data that I need to delete before I fill in the correct data. How can I send a series or even 1 'delete' key or 'backspace' key command to the active application? Is there a way to represent it in the string? I know carriage return is \r and new line is \n when i would program in C++, but i dont know what is the code for backspace or delete, and i dont even know if it works the same way in C# strings. Any help is appreciated, thanks

Share this post


Link to post
Share on other sites
Advertisement
Quote:
From SendKeys documentation:

To specify characters that aren't displayed when you press a key, such as ENTER or TAB, and keys that represent actions rather than characters, use the codes in the following table:
BACKSPACE: {BACKSPACE}

Share this post


Link to post
Share on other sites
[google]

if you google "SendKeys.Send" the very first link is the msdn documentation, which will tell you that backspace is {BACKSPACE}, {BS}, or {BKSP} and delete is {DELETE} or {DEL}

Share this post


Link to post
Share on other sites
In C/C++, you can use the '\b' escape character to represent a backspace, but it increases the string by one more character, so both the backspace representation and the character being "backspaced" are still in the string contributing to its length.

However, C# doesn't support this. I even tested it really quickly, and it shows a black bar with a white dot, kinda like half a domino.

But, you're in luck. (And you need to check MSDN out for these things more often.) Clickified link to MSDN's page for SendKeys.Send Method. Scrolling down a bit, it says that to use keys that are more actions than characters, you can enclose them. So "{BACKSPACE}" would create a backspace. This seems limited to the SendKeys.Sent, though.

Best o' luck.

[EDIT]
CURSE MY LONG WINDEDNESS, ALLOWING SEVERAL NINJAS IN HERE! D:
That and I was on #gamedev when Washu killed it today. >_>

Share this post


Link to post
Share on other sites
Thanks for all the replies. As for the google it suggestions, I always google first before asking in the forums, its just I really really suck at finding info, google or otherwise.

Thanks again.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!