How to send “{” or “}” signs through send keys method in vb 2010

谁都会走 提交于 2019-12-30 06:58:11

问题


I want to send { and } signs to the Active window in Visual Basic 2010.But the problem is when we send a key like "Backspace" we send it as "{BS}".So it also contains the { & } signs. Therefore when we send { and } signs nothing happen.Anyone help me...


回答1:


From

http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx

The plus sign (+), caret (^), percent sign (%), tilde (~), and parentheses () have special meanings to SendKeys. To specify one of these characters, enclose it within braces ({}). For example, to specify the plus sign, use "{+}". To specify brace characters, use "{{}" and "{}}". Brackets ([ ]) have no special meaning to SendKeys, but you must enclose them in braces. In other applications, brackets do have a special meaning that might be significant when dynamic data exchange (DDE) occurs.

Basically, you need to double up the braces to escape them, Like

{{}

to send a { opening brace, and

{}} 

to send a closing brace. It may not be obvious at first glance, but that's just enclosing a brace character within braces. This is consistent with other escape sequences, such as using \\ in C/C#/etc to indicate a literal \ instead of a string formatting character.



来源:https://stackoverflow.com/questions/7516137/how-to-send-or-signs-through-send-keys-method-in-vb-2010

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!