Page 1 of 1

Unable to use Keyboard.Press for typing HTML

Posted: Wed May 26, 2010 10:44 pm
by jlowder
Hi,

I have a variable that starts out:

string email = "<p>" +
"<ul>" +
"<li>POSTrxDiscAmt (The Products setting for the discount per POS swipe) = {[@POSTrxDiscAmt]}</li>" +

when attempting to execute:

Keyboard.Press(email);

I receive the error:

Unexpected exception occured: System.ArgumentException: '[@postrxdiscamt]' is not a valid member of the System.Windows.Forms.Keys enumeration.

How would I go about ensuring this just prints the string as I have it?

Thanks,

Jason

Re: Unable to use Keyboard.Press for typing HTML

Posted: Wed May 26, 2010 11:18 pm
by Ciege
Per the documentation of Keyboard.Press:
Only the '{' character has a special meaning and needs to be escaped by preceding it with another '{' (specify "{{" to issue a '{' key press).
So you need to add an extra { and } around your string {[@POSTrxDiscAmt]}

Re: Unable to use Keyboard.Press for typing HTML

Posted: Thu May 27, 2010 2:27 pm
by jlowder
Thank you. I actually did look at the documentation, but clearly was not paying attention...

Jason

Re: Unable to use Keyboard.Press for typing HTML

Posted: Thu May 27, 2010 3:50 pm
by Ciege
jlowder wrote:I actually did look at the documentation, but clearly was not paying attention...
Been there done that! I've had more slap myself on the forehead moments than I care to remember sometimes! :lol: