在RFT中发送键盘按键 - inputChars vs. inputkeys

 

RFT中,inputCharsinputkeys都可以给指定窗口发送按键。

inputKeys

public void inputKeys(java.lang.String keys)

Sends the supplied characters to the associated window. The window is responsible for sending the characters on to the appropriate controls nested in that window. The characters in the given string are interpreted according to the rules documented under ITopWindow.inputKeys.

Specified by:

inputKeys in interface ITopWindow

Parameters:

keys - the characters to be processed by this window

Since:

RFT1.1


 

例如,下面脚本将通过发送组合键ALT+H以及A键,控制菜单选择打开计算器的关于界面:

        计算器window().click(CAPTION);

        计算器window(ANY,MAY_EXIT).inputKeys("%ha");

       

组合键的标识符包括+^%~(){}:

The characters with special meanings are:
+^%~(){}

The meanings of these special characters are described as follows:

·   Tilde is a special character that is shorthand for the ENTER key:
~ Play back an ENTER  

~表示回车键

·   The following special characters modify the token that follows them:
+ Apply SHIFT to the character that follows immediately   +表示SHIFT键
^ Apply CONTROL to the character that follows immediately ^表示CTRL键
% Apply ALT to the character that follows immediately     %表示ALT键

For example, the following string plays back "ABCD":
"+a+b+c+d"

·   You can use parenthesis to group a set of characters on which the same modifier is applied. For example, the following plays back "ABCD":
"+(abcd)"

可以用()把一组字符括起来,前面的特殊字符对于括起来的一组都生效。

·   To play back a character with special meaning (rather than using it for its special meaning), enclose the character in curly braces. For example, the following string plays back "++++":
"{+}{+}{+}{+}"

用花括号对这些特殊字符进行转义。

·   You can specify a repeat count by enclosing the character in curly braces, followed by a space and then the count. For example, the following plays back "aaaa":
"{a 4}"

还可以用花括号表示重复指定字符一定的次数。

·   To play back only a key-down event for a character, enclose the character in curly braces, followed by a space and then KeyDn. To play back only a key-up event for a character, enclose the character in curly braces, followed by a space and then KeyUp. For example, the following plays back a complete "a" key-press:
"{a KeyDn}{a KeyUp}"

如果要表示按下或释放某个按键,需要在按键后空一个加KeyDn或KeyUp

·   Keys without print representation, for example, backspace, escape, print-screen, and so on, are tool-given names. To play back one of these keys, put its name in curly braces. The names are case-insensitive; for example, you can enter either {TAB} or {tab} and get the same result. Some keys have more than one name; for example, {BACKSPACE} and {BKSP} signify the same key. Following is a list of the names for all the unprintable characters. In this list, synonyms are listed next to each other: (下面是各种功能控制键的表示)

{CAPSLOCK} {NUMLOCK} {SCROLLLOCK} {ESCAPE} {ESC} {ENTER} {HELP} {PRTSC} {TAB} {BREAK} {CLEAR} {BACKSPACE} {BS} {BKSP} {DELETE} {DEL} {INSERT} {LEFT} {RIGHT} {UP} {DOWN} {PGUP} {PGDN} {HOME} {END} {F1} {F2} {F3} {F4} {F5} {F6} {F7} {F8} {F9} {F10} {F11} {F12} {F13} {F14} {F15} {F16} {APPS} {Win} {LEFTWIN} {RIGHTWIN} {CTRL} {SHIFT} {ALT} {LEFTCTRL} {LEFTSHIFT} {LEFTALT} {RIGHTCTRL} {RIGHTSHIFT} {RIGHTALT} {ExtDelete} {ExtInsert} {ExtLeft} {ExtRight} {ExtUp} {ExtDown} {ExtPgUp} {ExtPgDn} {ExtHome} {ExtEnd} {NumDelete} {NumInsert} {NumLeft} {NumRight} {NumUp} {NumDown} {NumPgUp} {NumPgDn} {NumHome} {NumEnd} {Num} {Num-} {Num/} {Num+} {Num~} {NumEnter} {Num0} {Num1} {Num2} {Num3} {Num4} {Num5} {Num6} {Num7} {Num8} {Num9} {Num.} >

Example:

Send "AB" to a password text field in classicJava application
passwordText().inputKeys("+a+b");

 

inputChars

inputKeys相反,inputChars发送的按键字符不会被解释。

 

public void inputChars(java.lang.String keys)

Sends the supplied characters to the associated window. The window is responsible for sending the characters on to the appropriate controls nested in that window. The characters are uninterpreted. For example, inputChars("+a+b") emits "+a+b", in contrast to inputKeys("+a+b"), which interprets the "+" as a shift and emits "AB".

Specified by:

inputChars in interface ITopWindow

Parameters:

keys - The characters to be processed by this window

Since:

RFT1.1

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值