-2

I'm trying to make my program press the " (Shift + 2 in the UK) when a button is pressed, but I'm not sure how to as when I enter..

SendKeys.Send(""");

It converts the latter part of the code to string.

Is there a way to make the program ignore a particular character? I'm not really sure how to go about this.

I'm making an on screen keyboard if anyone is wondering.

kaya3
  • 47,440
  • 4
  • 68
  • 97
Adam199990
  • 77
  • 5

3 Answers3

3

Escape the ", like so:

SendKeys.Send("\"");

Or use a string literal:

SendKeys.Send(@"""");

String literals in C# are usually nicer to read, but in this case, you still need to escape the single quote in the string literal, by doubling it.

In fact this is an interesting example of the one approach vs. the other:

"\""   // 4 chars, not very readable

vs:

@"""""   // 5 chars: even LESS readable: pretty confusing what it means
pb2q
  • 58,613
  • 19
  • 146
  • 147
0
SendKeys.Send("\"");

Something like this should work.

Have a look at this (what you're looking for is called escaping characters)

Bobby Tables
  • 2,953
  • 7
  • 29
  • 53
0

You can use escape characters:

SendKeys.Send("\"");

The \" translates to just ".

pb2q
  • 58,613
  • 19
  • 146
  • 147
Zarwan
  • 5,537
  • 4
  • 30
  • 48