设为首页 加入收藏

TOP

Python实现的基于ADB的Android远程工具(一)
2015-04-07 15:30:41 来源: 作者: 【 】 浏览:216
Tags:Python 实现 基于 ADB Android 远程 工具

- Python编程
- Tkinter GUI编程
- ADB通信机制


代码全文:


#!/usr/bin/env python
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# Android Robot 3.1
# This is a free software under GPL.
#
# Author: DiaoXuesong
# Bug report: wishcom@163.com
# ---------------------------------------------------------------------------
#
# Function:
# Screen cast via adb daemon, without java env.
# Usage:
#? arobot.py [-option]
# Example:
#? arobot.py
#? arobot.py -lcd
#? arobot.py -keypad


import subprocess,os
import threading
import socket,sys
import time


try:
? ? import Tkinter as tk
? ? import ttk
? ? from PIL import Image,ImageTk,ImageDraw
except:
? ? print 'Following module is needed:'
? ? print '- Tkinter: sudo apt-get install python-tk'
? ? print '- PIL: sudo apt-get install python-imaging-tk'
? ? sys.exit()


# Set DEBUG to True if you need know more running message
DEBUG = False


# Set USE_TTK to False if you need classic Tk/Tcl GUI-style
USE_TTK = True


'''
Key value definition refer from KeyEvent.java
public class KeyEvent extends InputEvent implements Parcelable {
? ? /** Key code constant: Unknown key code. */
? ? public static final int KEYCODE_UNKNOWN? ? ? ? = 0;
? ? public static final int KEYCODE_SOFT_LEFT? ? ? = 1;
? ? public static final int KEYCODE_SOFT_RIGHT? ? ? = 2;
? ? public static final int KEYCODE_HOME? ? ? ? ? ? = 3;
? ? public static final int KEYCODE_BACK? ? ? ? ? ? = 4;
? ? public static final int KEYCODE_CALL? ? ? ? ? ? = 5;
? ? public static final int KEYCODE_ENDCALL? ? ? ? = 6;
? ? public static final int KEYCODE_0? ? ? ? ? ? ? = 7;
? ? public static final int KEYCODE_1? ? ? ? ? ? ? = 8;
? ? public static final int KEYCODE_2? ? ? ? ? ? ? = 9;
? ? public static final int KEYCODE_3? ? ? ? ? ? ? = 10;
? ? public static final int KEYCODE_4? ? ? ? ? ? ? = 11;
? ? public static final int KEYCODE_5? ? ? ? ? ? ? = 12;
? ? public static final int KEYCODE_6? ? ? ? ? ? ? = 13;
? ? public static final int KEYCODE_7? ? ? ? ? ? ? = 14;
? ? public static final int KEYCODE_8? ? ? ? ? ? ? = 15;
? ? public static final int KEYCODE_9? ? ? ? ? ? ? = 16;
? ? public static final int KEYCODE_STAR? ? ? ? ? ? = 17;
? ? public static final int KEYCODE_POUND? ? ? ? ? = 18;
? ? public static final int KEYCODE_DPAD_UP? ? ? ? = 19;
? ? public static final int KEYCODE_DPAD_DOWN? ? ? = 20;
? ? public static final int KEYCODE_DPAD_LEFT? ? ? = 21;
? ? public static final int KEYCODE_DPAD_RIGHT? ? ? = 22;
? ? public static final int KEYCODE_DPAD_CENTER? ? = 23;
? ? public static final int KEYCODE_VOLUME_UP? ? ? = 24;
? ? public static final int KEYCODE_VOLUME_DOWN? ? = 25;
? ? public static final int KEYCODE_POWER? ? ? ? ? = 26;
? ? public static final int KEYCODE_CAMERA? ? ? ? ? = 27;
? ? public static final int KEYCODE_CLEAR? ? ? ? ? = 28;
? ? public static final int KEYCODE_A? ? ? ? ? ? ? = 29;
? ? public static final int KEYCODE_B? ? ? ? ? ? ? = 30;
? ? public static final int KEYCODE_C? ? ? ? ? ? ? = 31;
? ? public static final int KEYCODE_D? ? ? ? ? ? ? = 32;
? ? public static final int KEYCODE_E? ? ? ? ? ? ? = 33;
? ? public static final int KEYCODE_F? ? ? ? ? ? ? = 34;
? ? public static final int KEYCODE_G? ? ? ? ? ? ? = 35;
? ? public static final int KEYCODE_H? ? ? ? ? ? ? = 36;
? ? public static final int KEYCODE_I? ? ? ? ? ? ? = 37;
? ? public static final int KEYCODE_J? ? ? ? ? ? ? = 38;
? ? public static final int KEYCODE_K? ? ? ? ? ? ? = 39;
? ? public static final int KEYCODE_L? ? ? ? ? ? ? = 40;
? ? public static final int KEYCODE_M? ? ? ? ? ? ? = 41;
? ? public static final int KEYCODE_N? ? ? ? ? ? ? = 42;
? ? public static final int KEYCODE_O? ? ? ? ? ? ? = 43;
? ? public static final int KEYCODE_P? ? ? ? ? ? ? = 44;
? ? public static final int KEYCODE_Q? ? ? ? ? ? ? = 45;
? ? public static final int KEYCODE_R? ? ? ?

首页 上一页 1 2 3 4 5 6 7 下一页 尾页 1/11/11
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Python基础教程 - global关键字及.. 下一篇Python基础教程 - lambda关键字

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: