blob: ccf741b5263c15117c2c50f51392bf492c019476 [file] [log] [blame]
Bill Napiera68dbdb2009-08-07 11:34:12 -07001MONKEY NETWORK SCRIPT
2
3The Monkey Network Script was designed to be a low-level way to
4programmability inject KeyEvents and MotionEvents into the input
5system. The idea is that a process will run on a host computer that
6will support higher-level operations (like conditionals, etc.) and
7will talk (via TCP over ADB) to the device in Monkey Network Script.
8For security reasons, the Monkey only binds to localhost, so you will
9need to use adb to setup port forwarding to actually talk to the
10device.
11
12INITIAL SETUP
13
14Setup port forwarding from a local port on your machine to a port on
15the device:
16
17$ adb forward tcp:1080 tcp:1080
18
19Start the monkey server
20
21$ adb shell monkey --port 1080
22
23Now you're ready to run commands
24
25COMMAND LIST
26
27Individual commands are separated by newlines. The Monkey will
28respond to every command with a line starting with OK for commands
29that executed without a problem, or a line starting with ERROR for
30commands that had problems being run. The Monkey may decide to return
31more information about command execution. That information would come
32on the same line after the OK or ERROR. A possible example:
33
34key down menu
35OK
36touch monkey
37ERROR: monkey not a number
38
39The complete list of commands follows:
40
41key [down|up] keycode
42
43This command injects KeyEvent's into the input system. The keycode
44parameter refers to the KEYCODE list in the KeyEvent class
45(http://developer.android.com/reference/android/view/KeyEvent.html).
46The format of that parameter is quite flexible. Using the menu key as
47an example, it can be 82 (the integer value of the keycode),
48KEYCODE_MENU (the name of the keycode), or just menu (and the Monkey
49will add the KEYCODE part). Do note that this last part doesn't work
50for things like KEYCODE_1 for obvious reasons.
51
52Note that sending a full button press requires sending both the down
53and the up event for that key
54
55touch [down|up|move] x y
56
57This command injects a MotionEvent into the input system that
58simulates a user touching the touchscreen (or a pointer event). x and
59y specify coordinates on the display (0 0 being the upper left) for
60the touch event to happen. Just like key events, touch events at a
61single location require both a down and an up. To simulate dragging,
62send a "touch down", then a series of "touch move" events (to simulate
63the drag), followed by a "touch up" at the final location.
64
65trackball dx dy
66
67This command injects a MotionEvent into the input system that
68simulates a user using the trackball. dx and dy indicates the amount
69of change in the trackball location (as opposed to exact coordinates
70that the touch events use)
71
72flip [open|close]
73
74This simulates the opening or closing the keyboard (like on dream).
75
76OTHER NOTES
77
78There are some convenience features added to allow running without
79needing a host process.
80
81Lines starting with a # character are considered comments. The Monkey
82eats them and returns no indication that it did anything (no ERROR and
83no OK).
84
85You can put the Monkey to sleep by using the "sleep" command with a
86single argument, how many ms to sleep.