Unable to use Keyboard.Press for typing HTML

Ask general questions here.
jlowder
Posts: 55
Joined: Wed Dec 30, 2009 2:56 pm

Unable to use Keyboard.Press for typing HTML

Post by jlowder » Wed May 26, 2010 10:44 pm

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

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Unable to use Keyboard.Press for typing HTML

Post by Ciege » Wed May 26, 2010 11:18 pm

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]}
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

jlowder
Posts: 55
Joined: Wed Dec 30, 2009 2:56 pm

Re: Unable to use Keyboard.Press for typing HTML

Post by jlowder » Thu May 27, 2010 2:27 pm

Thank you. I actually did look at the documentation, but clearly was not paying attention...

Jason

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Unable to use Keyboard.Press for typing HTML

Post by Ciege » Thu May 27, 2010 3:50 pm

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:
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...