本文共 11887 字,大约阅读时间需要 39 分钟。
本章开始介绍下Monkeyrunner的API, 以便了解其具体的使用。
void press (string name, dictionary type) : 可以说是对键盘的操作
Sends the key event specified by type to the key specified by keycode.
Sends the key event specified by type
to the key specified by keycode
.
name | The name of the keycode to send. See KeyEvent for a list of keycode names. Use the keycode name, not its integer value. |
---|---|
type | The type of key event to send. The allowed values are DOWN , UP , and DOWN_AND_UP . |
E.g. 点击menu按钮
device.press('KEYCODE_MENU', MonkeyDevice.DOWN_AND_UP)
KeyEvent:
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | value: the key has been pressed down. | ||||||||||
int | value: multiple duplicate key events have occurred in a row, or a complex string is being delivered. | ||||||||||
int | value: the key has been released. | ||||||||||
int | When associated with up key events, this indicates that the key press has been canceled. | ||||||||||
int | Set when a key event has set because a long press action was executed while it was down. | ||||||||||
int | This mask is used for compatibility, to identify enter keys that are coming from an IME whose enter key has been auto-labelled "next" or "done". | ||||||||||
int | Set when a key event has been synthesized to implement default behavior for an event that the application did not handle. | ||||||||||
int | This mask is set if an event was known to come from a trusted part of the system. | ||||||||||
int | This mask is set if we don't want the key event to cause us to leave touch mode. | ||||||||||
int | This flag is set for the first key repeat that occurs after the long press timeout. | ||||||||||
int | This mask is set if the key event was generated by a software keyboard. | ||||||||||
int | Set for when this event's key code is still being tracked from its initial down. | ||||||||||
int | This key event was generated by a virtual (on-screen) hard key area. | ||||||||||
int | This mask is set if the device woke because of this key event. | ||||||||||
int | Key code constant: '0' key. | ||||||||||
int | Key code constant: '1' key. | ||||||||||
int | Key code constant: '2' key. | ||||||||||
int | Key code constant: '3' key. | ||||||||||
int | Key code constant: 3D Mode key. | ||||||||||
int | Key code constant: '4' key. | ||||||||||
int | Key code constant: '5' key. | ||||||||||
int | Key code constant: '6' key. | ||||||||||
int | Key code constant: '7' key. | ||||||||||
int | Key code constant: '8' key. | ||||||||||
int | Key code constant: '9' key. | ||||||||||
int | Key code constant: 'A' key. | ||||||||||
int | Key code constant: Left Alt modifier key. | ||||||||||
int | Key code constant: Right Alt modifier key. | ||||||||||
int | Key code constant: ''' (apostrophe) key. | ||||||||||
int | Key code constant: App switch key. | ||||||||||
int | Key code constant: '@' key. | ||||||||||
int | Key code constant: A/V Receiver input key. | ||||||||||
int | Key code constant: A/V Receiver power key. | ||||||||||
int | Key code constant: 'B' key. | ||||||||||
int | Key code constant: Back key. | ||||||||||
int | Key code constant: '\' key. | ||||||||||
int | Key code constant: Bookmark key. | ||||||||||
int | Key code constant: Break / Pause key. | ||||||||||
int | Key code constant: Generic Game Pad Button #1. | ||||||||||
int | Key code constant: Generic Game Pad Button #10. | ||||||||||
int | Key code constant: Generic Game Pad Button #11. | ||||||||||
int | Key code constant: Generic Game Pad Button #12. | ||||||||||
int | Key code constant: Generic Game Pad Button #13. | ||||||||||
int | Key code constant: Generic Game Pad Button #14. | ||||||||||
int | Key code constant: Generic Game Pad Button #15. | ||||||||||
int | Key code constant: Generic Game Pad Button #16. | ||||||||||
int | Key code constant: Generic Game Pad Button #2. | ||||||||||
int | Key code constant: Generic Game Pad Button #3. | ||||||||||
int | Key code constant: Generic Game Pad Button #4. | ||||||||||
int | Key code constant: Generic Game Pad Button #5. | ||||||||||
int | Key code constant: Generic Game Pad Button #6. | ||||||||||
int | Key code constant: Generic Game Pad Button #7. | ||||||||||
int | Key code constant: Generic Game Pad Button #8. | ||||||||||
int | Key code constant: Generic Game Pad Button #9. | ||||||||||
int | Key code constant: A Button key. | ||||||||||
int | Key code constant: B Button key. | ||||||||||
int | Key code constant: C Button key. | ||||||||||
int | Key code constant: L1 Button key. | ||||||||||
int | Key code constant: L2 Button key. | ||||||||||
int | Key code constant: Mode Button key. | ||||||||||
int | Key code constant: R1 Button key. | ||||||||||
int | Key code constant: R2 Button key. | ||||||||||
int | Key code constant: Select Button key. | ||||||||||
int | Key code constant: Start Button key. | ||||||||||
int | Key code constant: Left Thumb Button key. | ||||||||||
int | Key code constant: Right Thumb Button key. | ||||||||||
int | Key code constant: X Button key. | ||||||||||
int | Key code constant: Y Button key. | ||||||||||
int | Key code constant: Z Button key. | ||||||||||
int | Key code constant: 'C' key. | ||||||||||
int | Key code constant: Calculator special function key. | ||||||||||
int | Key code constant: Calendar special function key. | ||||||||||
int | Key code constant: Call key. | ||||||||||
int | Key code constant: Camera key. | ||||||||||
int | Key code constant: Caps Lock key. | ||||||||||
int | Key code constant: Toggle captions key. | ||||||||||
int | Key code constant: Channel down key. | ||||||||||
int | Key code constant: Channel up key. | ||||||||||
int | Key code constant: Clear key. | ||||||||||
int | Key code constant: ',' key. | ||||||||||
int | Key code constant: Contacts special function key. | ||||||||||
int | Key code constant: Left Control modifier key. | ||||||||||
int | Key code constant: Right Control modifier key. | ||||||||||
int | Key code constant: 'D' key. | ||||||||||
int | Key code constant: Backspace key. | ||||||||||
int | Key code constant: Directional Pad Center key. | ||||||||||
int | Key code constant: Directional Pad Down key. | ||||||||||
int | Key code constant: Directional Pad Left key. | ||||||||||
int | Key code constant: Directional Pad Right key. | ||||||||||
int | Key code constant: Directional Pad Up key. | ||||||||||
int | Key code constant: DVR key. | ||||||||||
int | Key code constant: 'E' key. | ||||||||||
int | Key code constant: End Call key. | ||||||||||
int | Key code constant: Enter key. | ||||||||||
int | Key code constant: Envelope special function key. | ||||||||||
int | Key code constant: '=' key. | ||||||||||
int | Key code constant: Escape key. | ||||||||||
int | Key code constant: Explorer special function key. | ||||||||||
int | Key code constant: 'F' key. | ||||||||||
int | Key code constant: F1 key. | ||||||||||
int | Key code constant: F10 key. | ||||||||||
int | Key code constant: F11 key. | ||||||||||
int | Key code constant: F12 key. | ||||||||||
int | Key code constant: F2 key. | ||||||||||
int | Key code constant: F3 key. | ||||||||||
int | Key code constant: F4 key. | ||||||||||
int | Key code constant: F5 key. | ||||||||||
int | Key code constant: F6 key. | ||||||||||
int | Key code constant: F7 key. | ||||||||||
int | Key code constant: F8 key. | ||||||||||
int | Key code constant: F9 key. | ||||||||||
int | Key code constant: Camera Focus key. | ||||||||||
int | Key code constant: Forward key. | ||||||||||
int | Key code constant: Forward Delete key. | ||||||||||
int | Key code constant: Function modifier key. | ||||||||||
int | Key code constant: 'G' key. | ||||||||||
int | Key code constant: '`' (backtick) key. | ||||||||||
int | Key code constant: Guide key. | ||||||||||
int | Key code constant: 'H' key. | ||||||||||
int | Key code constant: Headset Hook key. | ||||||||||
int | Key code constant: Home key. | ||||||||||
int | Key code constant: 'I' key. | ||||||||||
int | Key code constant: Info key. | ||||||||||
int | Key code constant: Insert key. | ||||||||||
int | Key code constant: 'J' key. | ||||||||||
int | Key code constant: 'K' key. | ||||||||||
int | Key code constant: 'L' key. | ||||||||||
int | Key code constant: Language Switch key. | ||||||||||
int | Key code constant: '[' key. | ||||||||||
int | Key code constant: 'M' key. | ||||||||||
int | Key code constant: Manner Mode key. | ||||||||||
int | Key code constant: Close media key. | ||||||||||
int | Key code constant: Eject media key. | ||||||||||
int | Key code constant: Fast Forward media key. | ||||||||||
int | Key code constant: Play Next media key. | ||||||||||
int | Key code constant: Pause media key. | ||||||||||
int | Key code constant: Play media key. | ||||||||||
int | Key code constant: Play/Pause media key. | ||||||||||
int | Key code constant: Play Previous media key. | ||||||||||
int | Key code constant: Record media key. | ||||||||||
int | Key code constant: Rewind media key. | ||||||||||
int | Key code constant: Stop media key. | ||||||||||
int | Key code constant: Menu key. | ||||||||||
int | Key code constant: Left Meta modifier key. | ||||||||||
int | Key code constant: Right Meta modifier key. | ||||||||||
int | Key code constant: '-'. | ||||||||||
int | Key code constant: End Movement key. | ||||||||||
int | Key code constant: Home Movement key. | ||||||||||
int | Key code constant: Music special function key. | ||||||||||
int | Key code constant: Mute key. | ||||||||||
int | Key code constant: 'N' key. | ||||||||||
int | Key code constant: Notification key. | ||||||||||
int | Key code constant: Number modifier key. | ||||||||||
int | Key code constant: Numeric keypad '0' key. | ||||||||||
int | Key code constant: Numeric keypad '1' key. | ||||||||||
int | Key code constant: Numeric keypad '2' key. | ||||||||||
int | Key code constant: Numeric keypad '3' key. | ||||||||||
int | Key code constant: Numeric keypad '4' key. | ||||||||||
int | Key code constant: Numeric keypad '5' key. | ||||||||||
int | Key code constant: Numeric keypad '6' key. | ||||||||||
int | Key code constant: Numeric keypad '7' key. | ||||||||||
int | Key code constant: Numeric keypad '8' key. | ||||||||||
int | Key code constant: Numeric keypad '9' key. | ||||||||||
int | Key code constant: Numeric keypad '+' key (for addition). | ||||||||||
int | Key code constant: Numeric keypad ',' key (for decimals or digit grouping). | ||||||||||
int | Key code constant: Numeric keypad '/' key (for division). | ||||||||||
int | Key code constant: Numeric keypad '.' key (for decimals or digit grouping). | ||||||||||
int | Key code constant: Numeric keypad Enter key. | ||||||||||
int | Key code constant: Numeric keypad '=' key. | ||||||||||
int | Key code constant: Numeric keypad '(' key. | ||||||||||
int | Key code constant: Numeric keypad '*' key (for multiplication). | ||||||||||
int | Key code constant: Numeric keypad ')' key. | ||||||||||
int | Key code constant: Numeric keypad '-' key (for subtraction). | ||||||||||
int | Key code constant: Num Lock key. | ||||||||||
int | Key code constant: 'O' key. | ||||||||||
int | Key code constant: 'P' key. | ||||||||||
int | Key code constant: Page Down key. | ||||||||||
int | Key code constant: Page Up key. | ||||||||||
int | Key code constant: '.' key. | ||||||||||
int | Key code constant: Picture Symbols modifier key. | ||||||||||
int | Key code constant: '+' key. | ||||||||||
int | Key code constant: '#' key. | ||||||||||
int | Key code constant: Power key. | ||||||||||
int | Key code constant: Blue "programmable" key. | ||||||||||
int | Key code constant: Green "programmable" key. | ||||||||||
int | Key code constant: Red "programmable" key. | ||||||||||
int | Key code constant: Yellow "programmable" key. | ||||||||||
int | Key code constant: 'Q' key. | ||||||||||
int | Key code constant: 'R' key. | ||||||||||
int | Key code constant: ']' key. | ||||||||||
int | Key code constant: 'S' key. | ||||||||||
int | Key code constant: Scroll Lock key. | ||||||||||
int | Key code constant: Search key. | ||||||||||
int | Key code constant: ';' key. | ||||||||||
int | Key code constant: Settings key. | ||||||||||
int | Key code constant: Left Shift modifier key. | ||||||||||
int | Key code constant: Right Shift modifier key. | ||||||||||
int | Key code constant: '/' key. | ||||||||||
int | Key code constant: Soft Left key. | ||||||||||
int | Key code constant: Soft Right key. | ||||||||||
int | Key code constant: Space key. | ||||||||||
int | Key code constant: '*' key. | ||||||||||
int | Key code constant: Set-top-box input key. | ||||||||||
int | Key code constant: Set-top-box power key. | ||||||||||
int | Key code constant: Switch Charset modifier key. | ||||||||||
int | Key code constant: Symbol modifier key. | ||||||||||
int | Key code constant: System Request / Print Screen key. | ||||||||||
int | Key code constant: 'T' key. | ||||||||||
int | Key code constant: Tab key. | ||||||||||
int | Key code constant: TV key. | ||||||||||
int | Key code constant: TV input key. | ||||||||||
int | Key code constant: TV power key. | ||||||||||
int | Key code constant: 'U' key. | ||||||||||
int | Key code constant: Unknown key code. | ||||||||||
int | Key code constant: 'V' key. | ||||||||||
int | Key code constant: Volume Down key. | ||||||||||
int | Key code constant: Volume Mute key. | ||||||||||
int | Key code constant: Volume Up key. | ||||||||||
int | Key code constant: 'W' key. | ||||||||||
int | Key code constant: Window key. | ||||||||||
int | Key code constant: 'X' key. | ||||||||||
int | Key code constant: 'Y' key. | ||||||||||
int | Key code constant: 'Z' key. | ||||||||||
int | Key code constant: Zoom in key. | ||||||||||
int | Key code constant: Zoom out key. | ||||||||||
int | This constant is deprecated. There are now more than MAX_KEYCODE keycodes. Use instead. | ||||||||||
int | This mask is used to check whether the left ALT meta key is pressed. | ||||||||||
int | This mask is a combination of , and . | ||||||||||
int | This mask is used to check whether one of the ALT meta keys is pressed. | ||||||||||
int | This mask is used to check whether the right the ALT meta key is pressed. | ||||||||||
int | This mask is used to check whether the CAPS LOCK meta key is on. | ||||||||||
int | This mask is used to check whether the left CTRL meta key is pressed. | ||||||||||
int | This mask is a combination of , and . | ||||||||||
int | This mask is used to check whether one of the CTRL meta keys is pressed. | ||||||||||
int | This mask is used to check whether the right CTRL meta key is pressed. | ||||||||||
int | This mask is used to check whether the FUNCTION meta key is pressed. | ||||||||||
int | This mask is used to check whether the left META meta key is pressed. | ||||||||||
int | This mask is a combination of , and . | ||||||||||
int | This mask is used to check whether one of the META meta keys is pressed. | ||||||||||
int | This mask is used to check whether the right META meta key is pressed. | ||||||||||
int | This mask is used to check whether the NUM LOCK meta key is on. | ||||||||||
int | This mask is used to check whether the SCROLL LOCK meta key is on. | ||||||||||
int | This mask is used to check whether the left SHIFT meta key is pressed. | ||||||||||
int | This mask is a combination of , and . | ||||||||||
int | This mask is used to check whether one of the SHIFT meta keys is pressed. | ||||||||||
int | This mask is used to check whether the right SHIFT meta key is pressed. | ||||||||||
int | This mask is used to check whether the SYM meta key is pressed. |
转载地址:http://gwjci.baihongyu.com/