【android】android使⽤命令模拟按键可以使⽤如下命令模拟android按键。
input keyevent keycode
keycode为具体的按键值,常⽤的如
HOME键为3,BACK键为4。
具体按键值在android中的定义如下:
field public static final int ACTION_DOWN = 0; // 0x0
field public static final int ACTION_MULTIPLE = 2; // 0x2
field public static final int ACTION_UP = 1; // 0x1
field public static final android.os.Parcelable.Creator<android.view.KeyEvent> CREATOR;
field public static final int FLAG_CANCELED = 32; // 0x20
field public static final int FLAG_CANCELED_LONG_PRESS = 256; // 0x100
field public static final int FLAG_EDITOR_ACTION = 16; // 0x10
field public static final int FLAG_FALLBACK = 1024; // 0x400
field public static final int FLAG_FROM_SYSTEM = 8; // 0x8
field public static final int FLAG_KEEP_TOUCH_MODE = 4; // 0x4
field public static final int FLAG_LONG_PRESS = 128; // 0x80
field public static final int FLAG_SOFT_KEYBOARD = 2; // 0x2
field public static final int FLAG_TRACKING = 512; // 0x200
field public static final int FLAG_VIRTUAL_HARD_KEY = 64; // 0x40
field public static final deprecated int FLAG_WOKE_HERE = 1; // 0x1
field public static final int KEYCODE_0 = 7; // 0x7
field public static final int KEYCODE_1 = 8; // 0x8
field public static final int KEYCODE_11 = 227; // 0xe3
field public static final int KEYCODE_12 = 228; // 0xe4
field public static final int KEYCODE_2 = 9; // 0x9
field public static final int KEYCODE_3 = 10; // 0xa
field public static final int KEYCODE_3D_MODE = 206; // 0xce
field public static final int KEYCODE_4 = 11; // 0xb
field public static final int KEYCODE_5 = 12; // 0xc
field public static final int KEYCODE_6 = 13; // 0xd
field public static final int KEYCODE_7 = 14; // 0xe
field public static final int KEYCODE_8 = 15; // 0xf
field public static final int KEYCODE_9 = 16; // 0x10
field public static final int KEYCODE_A = 29; // 0x1d
field public static final int KEYCODE_ALT_LEFT = 57; // 0x39
field public static final int KEYCODE_ALT_RIGHT = 58; // 0x3a
field public static final int KEYCODE_APOSTROPHE = 75; // 0x4b
field public static final int KEYCODE_APP_SWITCH = 187; // 0xbb
field public static final int KEYCODE_ASSIST = 219; // 0xdb
field public static final int KEYCODE_AT = 77; // 0x4d
field public static final int KEYCODE_AVR_INPUT = 182; // 0xb6
field public static final int KEYCODE_AVR_POWER = 181; // 0xb5
field public static final int KEYCODE_B = 30; // 0x1e
field public static final int KEYCODE_BACK = 4; // 0x4
field public static final int KEYCODE_BACKSLASH = 73; // 0x49
field public static final int KEYCODE_BOOKMARK = 174; // 0xae
field public static final int KEYCODE_BREAK = 121; // 0x79
field public static final int KEYCODE_BRIGHTNESS_DOWN = 220; // 0xdc
field public static final int KEYCODE_BRIGHTNESS_UP = 221; // 0xdd
field public static final int KEYCODE_BUTTON_1 = 188; // 0xbc
field public static final int KEYCODE_BUTTON_10 = 197; // 0xc5
field public static final int KEYCODE_BUTTON_11 = 198; // 0xc6
field public static final int KEYCODE_BUTTON_12 = 199; // 0xc7
field public static final int KEYCODE_BUTTON_13 = 200; // 0xc8
field public static final int KEYCODE_BUTTON_14 = 201; // 0xc9
field public static final int KEYCODE_BUTTON_14 = 201; // 0xc9
field public static final int KEYCODE_BUTTON_15 = 202; // 0xca
field public static final int KEYCODE_BUTTON_16 = 203; // 0xcb
field public static final int KEYCODE_BUTTON_2 = 189; // 0xbd
field public static final int KEYCODE_BUTTON_3 = 190; // 0xbe
field public static final int KEYCODE_BUTTON_4 = 191; // 0xbf
field public static final int KEYCODE_BUTTON_5 = 192; // 0xc0
field public static final int KEYCODE_BUTTON_6 = 193; // 0xc1
field public static final int KEYCODE_BUTTON_7 = 194; // 0xc2
field public static final int KEYCODE_BUTTON_8 = 195; // 0xc3
field public static final int KEYCODE_BUTTON_9 = 196; // 0xc4
field public static final int KEYCODE_BUTTON_A = 96; // 0x60
field public static final int KEYCODE_BUTTON_B = 97; // 0x61
field public static final int KEYCODE_BUTTON_C = 98; // 0x62
field public static final int KEYCODE_BUTTON_L1 = 102; // 0x66
field public static final int KEYCODE_BUTTON_L2 = 104; // 0x68
field public static final int KEYCODE_BUTTON_MODE = 110; // 0x6e    field public static final int KEYCODE_BUTTON_R1 = 103; // 0x67
field public static final int KEYCODE_BUTTON_R2 = 105; // 0x69
field public static final int KEYCODE_BUTTON_SELECT = 109; // 0x6d    field public static final int KEYCODE_BUTTON_START = 108; // 0x6c    field public static final int KEYCODE_BUTTON_THUMBL = 106; // 0x6a    field public static final int KEYCODE_BUTTON_THUMBR = 107; // 0x6b    field public static final int KEYCODE_BUTTON_X = 99; // 0x63
field public static final int KEYCODE_BUTTON_Y = 100; // 0x64
field public static final int KEYCODE_BUTTON_Z = 101; // 0x65
field public static final int KEYCODE_C = 31; // 0x1f
field public static final int KEYCODE_CALCULATOR = 210; // 0xd2
field public static final int KEYCODE_CALENDAR = 208; // 0xd0
field public static final int KEYCODE_CALL = 5; // 0x5
field public static final int KEYCODE_CAMERA = 27; // 0x1b
field public static final int KEYCODE_CAPS_LOCK = 115; // 0x73
field public static final int KEYCODE_CAPTIONS = 175; // 0xaf
field public static final int KEYCODE_CHANNEL_DOWN = 167; // 0xa7    field public static final int KEYCODE_CHANNEL_UP = 166; // 0xa6
field public static final int KEYCODE_CLEAR = 28; // 0x1c
field public static final int KEYCODE_COMMA = 55; // 0x37
field public static final int KEYCODE_CONTACTS = 207; // 0xcf
field public static final int KEYCODE_CTRL_LEFT = 113; // 0x71
field public static final int KEYCODE_CTRL_RIGHT = 114; // 0x72
field public static final int KEYCODE_D = 32; // 0x20
field public static final int KEYCODE_DEL = 67; // 0x43
field public static final int KEYCODE_DPAD_CENTER = 23; // 0x17
field public static final int KEYCODE_DPAD_DOWN = 20; // 0x14
field public static final int KEYCODE_DPAD_LEFT = 21; // 0x15
field public static final int KEYCODE_DPAD_RIGHT = 22; // 0x16
field public static final int KEYCODE_DPAD_UP = 19; // 0x13
field public static final int KEYCODE_DVR = 173; // 0xad
field public static final int KEYCODE_E = 33; // 0x21
field public static final int KEYCODE_EISU = 212; // 0xd4
field public static final int KEYCODE_ENDCALL = 6; // 0x6
field public static final int KEYCODE_ENTER = 66; // 0x42
field public static final int KEYCODE_ENVELOPE = 65; // 0x41
field public static final int KEYCODE_EQUALS = 70; // 0x46
field public static final int KEYCODE_ESCAPE = 111; // 0x6f
field public static final int KEYCODE_EXPLORER = 64; // 0x40
field public static final int KEYCODE_F = 34; // 0x22
field public static final int KEYCODE_F1 = 131; // 0x83
field public static final int KEYCODE_F10 = 140; // 0x8c
field public static final int KEYCODE_F11 = 141; // 0x8d
field public static final int KEYCODE_F12 = 142; // 0x8e
field public static final int KEYCODE_F2 = 132; // 0x84
field public static final int KEYCODE_F3 = 133; // 0x85
field public static final int KEYCODE_F4 = 134; // 0x86
field public static final int KEYCODE_F5 = 135; // 0x87
field public static final int KEYCODE_F6 = 136; // 0x88
field public static final int KEYCODE_F6 = 136; // 0x88
field public static final int KEYCODE_F7 = 137; // 0x89
field public static final int KEYCODE_F8 = 138; // 0x8a
field public static final int KEYCODE_F9 = 139; // 0x8b
field public static final int KEYCODE_FOCUS = 80; // 0x50
field public static final int KEYCODE_FORWARD = 125; // 0x7d
field public static final int KEYCODE_FORWARD_DEL = 112; // 0x70
field public static final int KEYCODE_FUNCTION = 119; // 0x77
field public static final int KEYCODE_G = 35; // 0x23
field public static final int KEYCODE_GRAVE = 68; // 0x44
field public static final int KEYCODE_GUIDE = 172; // 0xac
field public static final int KEYCODE_H = 36; // 0x24
field public static final int KEYCODE_HEADSETHOOK = 79; // 0x4f
field public static final int KEYCODE_HELP = 259; // 0x103
field public static final int KEYCODE_HENKAN = 214; // 0xd6
field public static final int KEYCODE_HOME = 3; // 0x3
field public static final int KEYCODE_I = 37; // 0x25
field public static final int KEYCODE_INFO = 165; // 0xa5
field public static final int KEYCODE_INSERT = 124; // 0x7c
field public static final int KEYCODE_J = 38; // 0x26
field public static final int KEYCODE_K = 39; // 0x27
field public static final int KEYCODE_KANA = 218; // 0xda
field public static final int KEYCODE_KATAKANA_HIRAGANA = 215; // 0xd7
field public static final int KEYCODE_L = 40; // 0x28
field public static final int KEYCODE_LANGUAGE_SWITCH = 204; // 0xcc
field public static final int KEYCODE_LAST_CHANNEL = 229; // 0xe5
field public static final int KEYCODE_LEFT_BRACKET = 71; // 0x47
field public static final int KEYCODE_M = 41; // 0x29
field public static final int KEYCODE_MANNER_MODE = 205; // 0xcd
field public static final int KEYCODE_MEDIA_AUDIO_TRACK = 222; // 0xde
field public static final int KEYCODE_MEDIA_CLOSE = 128; // 0x80
field public static final int KEYCODE_MEDIA_EJECT = 129; // 0x81
field public static final int KEYCODE_MEDIA_FAST_FORWARD = 90; // 0x5a
field public static final int KEYCODE_MEDIA_NEXT = 87; // 0x57
field public static final int KEYCODE_MEDIA_PAUSE = 127; // 0x7f
field public static final int KEYCODE_MEDIA_PLAY = 126; // 0x7e
field public static final int KEYCODE_MEDIA_PLAY_PAUSE = 85; // 0x55
field public static final int KEYCODE_MEDIA_PREVIOUS = 88; // 0x58
field public static final int KEYCODE_MEDIA_RECORD = 130; // 0x82
field public static final int KEYCODE_MEDIA_REWIND = 89; // 0x59
field public static final int KEYCODE_MEDIA_SKIP_BACKWARD = 273; // 0x111    field public static final int KEYCODE_MEDIA_SKIP_FORWARD = 272; // 0x110    field public static final int KEYCODE_MEDIA_STEP_BACKWARD = 275; // 0x113    field public static final int KEYCODE_MEDIA_STEP_FORWARD = 274; // 0x112    field public static final int KEYCODE_MEDIA_STOP = 86; // 0x56
field public static final int KEYCODE_MEDIA_TOP_MENU = 226; // 0xe2
field public static final int KEYCODE_MENU = 82; // 0x52
field public static final int KEYCODE_META_LEFT = 117; // 0x75
field public static final int KEYCODE_META_RIGHT = 118; // 0x76
field public static final int KEYCODE_MINUS = 69; // 0x45
field public static final int KEYCODE_MOVE_END = 123; // 0x7b
field public static final int KEYCODE_MOVE_HOME = 122; // 0x7a
field public static final int KEYCODE_MUHENKAN = 213; // 0xd5
field public static final int KEYCODE_MUSIC = 209; // 0xd1
field public static final int KEYCODE_MUTE = 91; // 0x5b
field public static final int KEYCODE_N = 42; // 0x2a
field public static final int KEYCODE_NAVIGATE_IN = 262; // 0x106
field public static final int KEYCODE_NAVIGATE_NEXT = 261; // 0x105
field public static final int KEYCODE_NAVIGATE_OUT = 263; // 0x107
field public static final int KEYCODE_NAVIGATE_PREVIOUS = 260; // 0x104
field public static final int KEYCODE_NOTIFICATION = 83; // 0x53
field public static final int KEYCODE_NUM = 78; // 0x4e
field public static final int KEYCODE_NUMPAD_0 = 144; // 0x90
field public static final int KEYCODE_NUMPAD_1 = 145; // 0x91
field public static final int KEYCODE_NUMPAD_2 = 146; // 0x92
field public static final int KEYCODE_NUMPAD_3 = 147; // 0x93
field public static final int KEYCODE_NUMPAD_3 = 147; // 0x93
field public static final int KEYCODE_NUMPAD_4 = 148; // 0x94
field public static final int KEYCODE_NUMPAD_5 = 149; // 0x95
field public static final int KEYCODE_NUMPAD_6 = 150; // 0x96
field public static final int KEYCODE_NUMPAD_7 = 151; // 0x97
field public static final int KEYCODE_NUMPAD_8 = 152; // 0x98
field public static final int KEYCODE_NUMPAD_9 = 153; // 0x99
field public static final int KEYCODE_NUMPAD_ADD = 157; // 0x9d
field public static final int KEYCODE_NUMPAD_COMMA = 159; // 0x9f
field public static final int KEYCODE_NUMPAD_DIVIDE = 154; // 0x9a
field public static final int KEYCODE_NUMPAD_DOT = 158; // 0x9e
field public static final int KEYCODE_NUMPAD_ENTER = 160; // 0xa0
field public static final int KEYCODE_NUMPAD_EQUALS = 161; // 0xa1
field public static final int KEYCODE_NUMPAD_LEFT_PAREN = 162; // 0xa2
field public static final int KEYCODE_NUMPAD_MULTIPLY = 155; // 0x9b
field public static final int KEYCODE_NUMPAD_RIGHT_PAREN = 163; // 0xa3
field public static final int KEYCODE_NUMPAD_SUBTRACT = 156; // 0x9c
field public static final int KEYCODE_NUM_LOCK = 143; // 0x8f
field public static final int KEYCODE_O = 43; // 0x2b
field public static final int KEYCODE_P = 44; // 0x2c
field public static final int KEYCODE_PAGE_DOWN = 93; // 0x5d
field public static final int KEYCODE_PAGE_UP = 92; // 0x5c
field public static final int KEYCODE_PAIRING = 225; // 0xe1
field public static final int KEYCODE_PERIOD = 56; // 0x38
field public static final int KEYCODE_PICTSYMBOLS = 94; // 0x5e
field public static final int KEYCODE_PLUS = 81; // 0x51
field public static final int KEYCODE_POUND = 18; // 0x12
field public static final int KEYCODE_POWER = 26; // 0x1a
field public static final int KEYCODE_PROG_BLUE = 186; // 0xba
field public static final int KEYCODE_PROG_GREEN = 184; // 0xb8
field public static final int KEYCODE_PROG_RED = 183; // 0xb7
field public static final int KEYCODE_PROG_YELLOW = 185; // 0xb9
field public static final int KEYCODE_Q = 45; // 0x2d
field public static final int KEYCODE_R = 46; // 0x2e
field public static final int KEYCODE_RIGHT_BRACKET = 72; // 0x48
field public static final int KEYCODE_RO = 217; // 0xd9
field public static final int KEYCODE_S = 47; // 0x2f
field public static final int KEYCODE_SCROLL_LOCK = 116; // 0x74
android模拟点击
field public static final int KEYCODE_SEARCH = 84; // 0x54
field public static final int KEYCODE_SEMICOLON = 74; // 0x4a
field public static final int KEYCODE_SETTINGS = 176; // 0xb0
field public static final int KEYCODE_SHIFT_LEFT = 59; // 0x3b
field public static final int KEYCODE_SHIFT_RIGHT = 60; // 0x3c
field public static final int KEYCODE_SLASH = 76; // 0x4c
field public static final int KEYCODE_SLEEP = 223; // 0xdf
field public static final int KEYCODE_SOFT_LEFT = 1; // 0x1
field public static final int KEYCODE_SOFT_RIGHT = 2; // 0x2
field public static final int KEYCODE_SPACE = 62; // 0x3e
field public static final int KEYCODE_STAR = 17; // 0x11
field public static final int KEYCODE_STB_INPUT = 180; // 0xb4
field public static final int KEYCODE_STB_POWER = 179; // 0xb3
field public static final int KEYCODE_SWITCH_CHARSET = 95; // 0x5f
field public static final int KEYCODE_SYM = 63; // 0x3f
field public static final int KEYCODE_SYSRQ = 120; // 0x78
field public static final int KEYCODE_T = 48; // 0x30
field public static final int KEYCODE_TAB = 61; // 0x3d
field public static final int KEYCODE_TV = 170; // 0xaa
field public static final int KEYCODE_TV_ANTENNA_CABLE = 242; // 0xf2
field public static final int KEYCODE_TV_AUDIO_DESCRIPTION = 252; // 0xfc
field public static final int KEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN = 254; // 0xfe    field public static final int KEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP = 253; // 0xfd
field public static final int KEYCODE_TV_CONTENTS_MENU = 256; // 0x100
field public static final int KEYCODE_TV_DATA_SERVICE = 230; // 0xe6
field public static final int KEYCODE_TV_INPUT = 178; // 0xb2
field public static final int KEYCODE_TV_INPUT_COMPONENT_1 = 249; // 0xf9
field public static final int KEYCODE_TV_INPUT_COMPONENT_2 = 250; // 0xfa
field public static final int KEYCODE_TV_INPUT_COMPONENT_2 = 250; // 0xfa
field public static final int KEYCODE_TV_INPUT_COMPOSITE_1 = 247; // 0xf7
field public static final int KEYCODE_TV_INPUT_COMPOSITE_2 = 248; // 0xf8
field public static final int KEYCODE_TV_INPUT_HDMI_1 = 243; // 0xf3
field public static final int KEYCODE_TV_INPUT_HDMI_2 = 244; // 0xf4
field public static final int KEYCODE_TV_INPUT_HDMI_3 = 245; // 0xf5
field public static final int KEYCODE_TV_INPUT_HDMI_4 = 246; // 0xf6
field public static final int KEYCODE_TV_INPUT_VGA_1 = 251; // 0xfb
field public static final int KEYCODE_TV_MEDIA_CONTEXT_MENU = 257; // 0x101    field public static final int KEYCODE_TV_NETWORK = 241; // 0xf1
field public static final int KEYCODE_TV_NUMBER_ENTRY = 234; // 0xea
field public static final int KEYCODE_TV_POWER = 177; // 0xb1
field public static final int KEYCODE_TV_RADIO_SERVICE = 232; // 0xe8
field public static final int KEYCODE_TV_SATELLITE = 237; // 0xed
field public static final int KEYCODE_TV_SATELLITE_BS = 238; // 0xee
field public static final int KEYCODE_TV_SATELLITE_CS = 239; // 0xef
field public static final int KEYCODE_TV_SATELLITE_SERVICE = 240; // 0xf0
field public static final int KEYCODE_TV_TELETEXT = 233; // 0xe9
field public static final int KEYCODE_TV_TERRESTRIAL_ANALOG = 235; // 0xeb    field public static final int KEYCODE_TV_TERRESTRIAL_DIGITAL = 236; // 0xec    field public static final int KEYCODE_TV_TIMER_PROGRAMMING = 258; // 0x102    field public static final int KEYCODE_TV_ZOOM_MODE = 255; // 0xff
field public static final int KEYCODE_U = 49; // 0x31
field public static final int KEYCODE_UNKNOWN = 0; // 0x0
field public static final int KEYCODE_V = 50; // 0x32
field public static final int KEYCODE_VOICE_ASSIST = 231; // 0xe7
field public static final int KEYCODE_VOLUME_DOWN = 25; // 0x19
field public static final int KEYCODE_VOLUME_MUTE = 164; // 0xa4
field public static final int KEYCODE_VOLUME_UP = 24; // 0x18
field public static final int KEYCODE_W = 51; // 0x33
field public static final int KEYCODE_WAKEUP = 224; // 0xe0
field public static final int KEYCODE_WINDOW = 171; // 0xab
field public static final int KEYCODE_X = 52; // 0x34
field public static final int KEYCODE_Y = 53; // 0x35
field public static final int KEYCODE_YEN = 216; // 0xd8
field public static final int KEYCODE_Z = 54; // 0x36
field public static final int KEYCODE_ZENKAKU_HANKAKU = 211; // 0xd3
field public static final int KEYCODE_ZOOM_IN = 168; // 0xa8
field public static final int KEYCODE_ZOOM_OUT = 169; // 0xa9
field public static final deprecated int MAX_KEYCODE = 84; // 0x54

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。