---
title: "使用Monkey运行脚本测试"
author: "wait_miracle"
date: "2014-02-07T17:16:52Z"
tags: []
categories: ["移动开发"]
slug: "monkey"
draft: false
lastmod: "2014-02-07T17:16:52Z"
id: 2012113
url: "https://wait-miracle.iteye.com/blog/2012113"
---

**一次性输入** **example\_script.txt** **脚步里面的所有内容，命令如下：**

              root@lenovo-desktop:~# cat example\_script.txt | telnet 127.0.0.1 1080

       这时，你就可以在你执行 # monkey --port 1080 -v –v 命令的窗口看到打印的一系列 Events 消息：

              …

              ……

              :Sending Pointer ACTION\_DOWN x=160.0 y=200.0

:Sending Pointer ACTION\_UP x=160.0 y=200.0

Sleeping for 1000 milliseconds

:Sending Pointer ACTION\_DOWN x=300.0 y=450.0

:Sending Pointer ACTION\_UP x=300.0 y=450.0

Sleeping for 1000 milliseconds

:Sending Pointer ACTION\_DOWN x=300.0 y=450.0

:Sending Pointer ACTION\_UP x=300.0 y=450.0

Sleeping for 1000 milliseconds

:Sending Pointer ACTION\_DOWN x=300.0 y=450.0

:Sending Pointer ACTION\_UP x=300.0 y=450.0

Sleeping for 1000 milliseconds

:SendKey (ACTION\_DOWN): 20    // KEYCODE\_DPAD\_DOWN

:SendKey (ACTION\_UP): 20    // KEYCODE\_DPAD\_DOWN

:SendKey (ACTION\_DOWN): 20    // KEYCODE\_DPAD\_DOWN

:SendKey (ACTION\_UP): 20    // KEYCODE\_DPAD\_DOWN

:SendKey (ACTION\_DOWN): 23    // KEYCODE\_DPAD\_CENTER

:SendKey (ACTION\_UP): 23    // KEYCODE\_DPAD\_CENTER

:SendKey (ACTION\_DOWN): 30    // KEYCODE\_B

:SendKey (ACTION\_UP): 30    // KEYCODE\_B

:SendKey (ACTION\_DOWN): 37    // KEYCODE\_I

:SendKey (ACTION\_UP): 37    // KEYCODE\_I

:SendKey (ACTION\_DOWN): 40    // KEYCODE\_L

:SendKey (ACTION\_UP): 40    // KEYCODE\_L

:SendKey (ACTION\_DOWN): 40    // KEYCODE\_L

:SendKey (ACTION\_UP): 40    // KEYCODE\_L

:SendKey (ACTION\_DOWN): 20    // KEYCODE\_DPAD\_DOWN

:SendKey (ACTION\_UP): 20    // KEYCODE\_DPAD\_DOWN

:SendKey (ACTION\_DOWN): 30    // KEYCODE\_B

:SendKey (ACTION\_UP): 30    // KEYCODE\_B

:SendKey (ACTION\_DOWN): 37    // KEYCODE\_I

:SendKey (ACTION\_UP): 37    // KEYCODE\_I

:SendKey (ACTION\_DOWN): 40    // KEYCODE\_L

:SendKey (ACTION\_UP): 40    // KEYCODE\_L

:SendKey (ACTION\_DOWN): 40    // KEYCODE\_L

:SendKey (ACTION\_UP): 40    // KEYCODE\_L

:Sending Pointer ACTION\_DOWN x=300.0 y=450.0

:Sending Pointer ACTION\_UP x=300.0 y=450.0

Events injected: 34

:Dropped: keys=0 pointers=0 trackballs=0 flips=0

\## Network stats: elapsed time=18299ms (18299ms mobile, 0ms wifi, 0ms not connected)

 

注：你发现没？以上显示的内容呢，正是 examp\_script.txt 的内容。