转自:http://www.cnblogs.com/leaven/archive/2010/11/30/1891947.html

  1. 查看/dev/input/eventX是什么类型的事件, cat /proc/bus/input/devices
  2. 设备有着自己特殊的按键键码,我需要将一些标准的按键,比如0-,XZ等模拟成标准按键,比如KEY_0,KEY-Z等,所以需要用到按键模拟,具体方法就是操作/dev/input/event1文件,向它写入个input_event结构体就可以模拟按键的输入了。
  3. linux/input.h中有定义,这个文件还定义了标准按键的编码等
  4. struct input_event {
  5. struct timeval time; //按键时间
  6. __u16 type; //类型,在下面有定义
  7. __u16 code; //要模拟成什么按键
  8. __s32 value;//是按下还是释放
  9. };
  10. code
  11. 事件的代码.如果事件的类型代码是EV_KEY,该代码code为设备键盘代码.代码植0~127为键盘上的按键代码,0x110~0x116 为鼠标上按键代码,其中0x110(BTN_ LEFT)为鼠标左键,0x111(BTN_RIGHT)为鼠标右键,0x112(BTN_ MIDDLE)为鼠标中键.其它代码含义请参看include/linux/input.h文件. 如果事件的类型代码是EV_REL,code值表示轨迹的类型.如指示鼠标的X轴方向REL_X(代码为0x00),指示鼠标的Y轴方向REL_Y(代码为0x01),指示鼠标中轮子方向REL_WHEEL(代码为0x08).
  12. type:
  13. EV_KEY,键盘
  14. EV_REL,相对坐标
  15. EV_ABS,绝对坐标
  16. value
  17. 事件的值.如果事件的类型代码是EV_KEY,当按键按下时值为1,松开时值为0;如果事件的类型代码是EV_ REL,value的正数值和负数值分别代表两个不同方向的值.
  18. /*
  19. * Event types
  20. */
  21. #define EV_SYN 0x00
  22. #define EV_KEY 0x01 //按键
  23. #define EV_REL 0x02 //相对坐标(轨迹球)
  24. #define EV_ABS 0x03 //绝对坐标
  25. #define EV_MSC 0x04 //其他
  26. #define EV_SW 0x05
  27. #define EV_LED 0x11 //LED
  28. #define EV_SND 0x12//声音
  29. #define EV_REP 0x14//repeat
  30. #define EV_FF 0x15
  31. #define EV_PWR 0x16
  32. #define EV_FF_STATUS 0x17
  33. #define EV_MAX 0x1f
  34. #define EV_CNT (EV_MAX+1)
  35. 。模拟按键输入
  36. //其中0表示释放,1按键按下,2表示一直按下
  37. //0 for EV_KEY for release, 1 for keypress and 2 for autorepeat.
  38. void simulate_key(int fd,int value)
  39. {
  40. struct input_event event;
  41. event.type = EV_KEY;
  42. //event.code = KEY_0;//要模拟成什么按键
  43. event.value = value;//是按下还是释放按键或者重复
  44. gettimeofday(&event.time,);
  45. if(write(fd,&event,sizeof(event)) < ){
  46. dprintk("simulate key error~~~\n");
  47. return ;
  48. }
  49. }
  50. 。模拟鼠标输入(轨迹球)
  51. void simulate_mouse(int fd,char buf[])
  52. {
  53. int rel_x,rel_y;
  54. static struct input_event event,ev;
  55. //buf[0],buf[2],小于0则为左移,大于0则为右移
  56. //buf[1],buf[3],小于0则为下移,大于0则为上移
  57. dprintk("MOUSE TOUCH: x1=%d,y1=%d,x2=%d,y2=%d\n",buf[],buf[],buf[],buf[]);
  58. rel_x = (buf[] + buf[]) /;
  59. rel_y = -(buf[] + buf[]) /; //和我们的鼠标是相反的方向,所以取反
  60. event.type = EV_REL;
  61. event.code = REL_X;
  62. event.value = rel_x;
  63. gettimeofday(&event.time,);
  64. if( write(fd,&event,sizeof(event))!=sizeof(event))
  65. dprintk("rel_x error~~~:%s\n",strerror(errno));
  66. event.code = REL_Y;
  67. event.value = rel_y;
  68. gettimeofday(&event.time,);
  69. if( write(fd,&event,sizeof(event))!=sizeof(event))
  70. dprintk("rel_y error~~~:%s\n",strerror(errno));
  71. //一定要刷新空的
  72. write(fd,&ev,sizeof(ev));
  73. }
  74. 鼠标和键盘文件打开方法:
  75. int fd_kbd; // /dev/input/event1
  76. int fd_mouse; //dev/input/mouse2
  77. fd_kbd = open("/dev/input/event1",O_RDWR);
  78. if(fd_kbd<=){
  79. printf("error open keyboard:%s\n",strerror(errno));
  80. return -;
  81. }
  82. fd_mouse = open("/dev/input/event3",O_RDWR); //如果不行的话,那试试/dev/input/mice
  83. if(fd_mouse<=){
  84. printf("error open mouse:%s\n",strerror(errno));
  85. return -;
  86. }
  87. }
  88. /dev/input/mice是鼠标的抽象,代表的是鼠标,也许是/dev/input/mouse,/dev/input/mouse1,或者空,
  89. 这个文件一直会存在。
  90. 这里你也许会问,我怎么知道/dev/input/eventX这些事件到底是什么事件阿,是鼠标还是键盘或者别的,
  91. eventX代表的是所有输入设备(input核心)的事件,比如按键按下,或者鼠标移动,或者游戏遥控器等等,
  92. 在系统查看的方法是 cat /proc/bus/input/devices 就可以看到每个eventX是什么设备的事件了。
  93. PS: GTK中用的话,可以参考下gtk_main_do_event这个函数
  94. static void simulate_key(GtkWidget *window,int keyval,int press)
  95. {
  96. GdkEvent *event;
  97. GdkEventType type;
  98. if(press)
  99. type = GDK_KEY_PRESS;
  100. else
  101. type = GDK_KEY_RELEASE;
  102. event = gdk_event_new(type);
  103. //event->key.send_event = TRUE;
  104. event->key.window = window->window; //一定要设置为主窗口
  105. event->key.keyval = keyval;
  106. //FIXME:一定要加上这个,要不然容易出错
  107. g_object_ref(event->key.window);
  108. gdk_threads_enter();
  109. //FIXME: 记得用这个来发送事件
  110. gtk_main_do_event(event);
  111. gdk_threads_leave();
  112. gdk_event_free(event);
  113. }
  114. kernelinput模块
  115. input_dev结构:
  116. struct input_dev {
  117. void *private;
  118. const char *name;
  119. const char *phys;
  120. const char *uniq;
  121. struct input_id id;
  122. /*
  123. * 根据各种输入信号的类型来建立类型为unsigned long 的数组,
  124. * 数组的每1bit代表一种信号类型,
  125. * 内核中会对其进行置位或清位操作来表示时间的发生和被处理.
  126. */
  127. unsigned long evbit[NBITS(EV_MAX)];
  128. unsigned long keybit[NBITS(KEY_MAX)];
  129. unsigned long relbit[NBITS(REL_MAX)];
  130. unsigned long absbit[NBITS(ABS_MAX)];
  131. unsigned long mscbit[NBITS(MSC_MAX)];
  132. unsigned long ledbit[NBITS(LED_MAX)];
  133. unsigned long sndbit[NBITS(SND_MAX)];
  134. unsigned long ffbit[NBITS(FF_MAX)];
  135. unsigned long swbit[NBITS(SW_MAX)];
  136. .........................................
  137. };
  138. /**
  139. * input_set_capability - mark device as capable of a certain event
  140. * @dev: device that is capable of emitting or accepting event
  141. * @type: type of the event (EV_KEY, EV_REL, etc...)
  142. * @code: event code
  143. *
  144. * In addition to setting up corresponding bit in appropriate capability
  145. * bitmap the function also adjusts dev->evbit.
  146. */
  147. /* 记录本设备对于哪些事件感兴趣(对其进行处理)*/
  148. void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int code)
  149. {
  150. switch (type) {
  151. case EV_KEY:
  152. __set_bit(code, dev->keybit);//比如按键,应该对哪些键值的按键进行处理(对于其它按键不予理睬)
  153. break;
  154. case EV_REL:
  155. __set_bit(code, dev->relbit);
  156. break;
  157. case EV_ABS:
  158. __set_bit(code, dev->absbit);
  159. break;
  160. case EV_MSC:
  161. __set_bit(code, dev->mscbit);
  162. break;
  163. case EV_SW:
  164. __set_bit(code, dev->swbit);
  165. break;
  166. case EV_LED:
  167. __set_bit(code, dev->ledbit);
  168. break;
  169. case EV_SND:
  170. __set_bit(code, dev->sndbit);
  171. break;
  172. case EV_FF:
  173. __set_bit(code, dev->ffbit);
  174. break;
  175. default:
  176. printk(KERN_ERR
  177. "input_set_capability: unknown type %u (code %u)\n",
  178. type, code);
  179. dump_stack();
  180. return;
  181. }
  182. __set_bit(type, dev->evbit);//感觉和前面重复了(前面一经配置过一次了)
  183. }
  184. EXPORT_SYMBOL(input_set_capability);
  185. static irqreturn_t gpio_keys_isr(int irq, void *dev_id)
  186. {
  187. int i;
  188. struct platform_device *pdev = dev_id;
  189. struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
  190. struct input_dev *input = platform_get_drvdata(pdev);
  191. for (i = ; i < pdata->nbuttons; i++) {
  192. struct gpio_keys_button *button = &pdata->buttons[i];
  193. int gpio = button->gpio;
  194. if (irq == gpio_to_irq(gpio)) {//判断哪个键被按了?
  195. unsigned int type = button->type ?: EV_KEY;
  196. int state = (gpio_get_value(gpio) ? : ) ^ button->active_low;//记录按键状态
  197. input_event(input, type, button->code, !!state);//汇报输入事件
  198. input_sync(input);//等待输入事件处理完成
  199. }
  200. }
  201. return IRQ_HANDLED;
  202. }
  203. /*
  204. * input_event() - report new input event
  205. * @dev: device that generated the event
  206. * @type: type of the event
  207. * @code: event code
  208. * @value: value of the event
  209. *
  210. * This function should be used by drivers implementing various input devices
  211. * See also input_inject_event()
  212. */
  213. void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
  214. {
  215. struct input_handle *handle;
  216. if (type > EV_MAX || !test_bit(type, dev->evbit))//首先判断该事件类型是否有效且为该设备所接受
  217. return;
  218. add_input_randomness(type, code, value);
  219. switch (type) {
  220. case EV_SYN:
  221. switch (code) {
  222. case SYN_CONFIG:
  223. if (dev->event)
  224. dev->event(dev, type, code, value);
  225. break;
  226. case SYN_REPORT:
  227. if (dev->sync)
  228. return;
  229. dev->sync = ;
  230. break;
  231. }
  232. break;
  233. case EV_KEY:
  234. /*
  235. * 这里需要满足几个条件:
  236. * 1: 键值有效(不超出定义的键值的有效范围)
  237. * 2: 键值为设备所能接受(属于该设备所拥有的键值范围)
  238. * 3: 按键状态改变了
  239. */
  240. if (code > KEY_MAX || !test_bit(code, dev->keybit) || !!test_bit(code, dev->key) == value)
  241. return;
  242. if (value == )
  243. break;
  244. change_bit(code, dev->key);//改变对应按键的状态
  245. /* 如果你希望按键未释放的时候不断汇报按键事件的话需要以下这个(在简单的gpio_keys驱动中不需要这个,暂时不去分析) */
  246. if (test_bit(EV_REP, dev->evbit) && dev->rep[REP_PERIOD] && dev->rep[REP_DELAY] && dev->timer.data && value) {
  247. dev->repeat_key = code;
  248. mod_timer(&dev->timer, jiffies + msecs_to_jiffies(dev->rep[REP_DELAY]));
  249. }
  250. break;
  251. ........................................................
  252. if (type != EV_SYN)
  253. dev->sync = ;
  254. if (dev->grab)
  255. dev->grab->handler->event(dev->grab, type, code, value);
  256. else
  257. /*
  258. * 循环调用所有处理该设备的handle(event,mouse,ts,joy等),
  259. * 如果有进程打开了这些handle(进行读写),则调用其对应的event接口向气汇报该输入事件.
  260. */
  261. list_for_each_entry(handle, &dev->h_list, d_node)
  262. if (handle->open)
  263. handle->handler->event(handle, type, code, value);
  264. }
  265. EXPORT_SYMBOL(input_event);
  266. event层对于input层报告的这个键盘输入事件的处理:
  267. drivers/input/evdev.c:
  268. static struct input_handler evdev_handler = {
  269. .event = evdev_event,
  270. .connect = evdev_connect,
  271. .disconnect = evdev_disconnect,
  272. .fops = &evdev_fops,
  273. .minor = EVDEV_MINOR_BASE,
  274. .name = "evdev",
  275. .id_table = evdev_ids,
  276. };
  277.  
  278. Linux 有自己的 input 子系统,可以统一管理鼠标和键盘事件。
  279. 基于输入子系统 实现的 uinput 可以方便的在用户空间模拟鼠标和键盘事件。
  280. 当然,也可以自己造轮子, 做一个字符设备接收用户输入,根据输入,投递 input 事件。
  281. 还有一种方式就是直接 evnent 里写入数据, 都可以达到控制鼠标键盘的功能。
  282.  
  283. 本篇文章就是演示直接写入 event 的方法。
  284. linux/input.h中有定义,这个文件还定义了标准按键的编码等
  285.  
  286. struct input_event {
  287. struct timeval time; //按键时间
  288. __u16 type; //类型,在下面有定义
  289. __u16 code; //要模拟成什么按键
  290. __s32 value;//是按下还是释放
  291. };
  292.  
  293. code
  294. 事件的代码.如果事件的类型代码是EV_KEY,该代码code为设备键盘代码.代码植0~127为键盘上的按键代码, 0x110~0x116 为鼠标上按键代码,其中0x110(BTN_ LEFT)为鼠标左键,0x111(BTN_RIGHT)为鼠标右键,0x112(BTN_ MIDDLE)为鼠标中键.其它代码含义请参看include/linux /input.h文件. 如果事件的类型代码是EV_REL,code值表示轨迹的类型.如指示鼠标的X轴方向 REL_X (代码为0x00),指示鼠标的Y轴方向REL_Y(代码为0x01),指示鼠标中轮子方向REL_WHEEL(代码为0x08).
  295.  
  296. type:
  297. EV_KEY,键盘
  298. EV_REL,相对坐标
  299. EV_ABS,绝对坐标
  300.  
  301. value
  302. 事件的值.如果事件的类型代码是EV_KEY,当按键按下时值为1,松开时值为0;如果事件的类型代码是EV_ REL,value的正数值和负数值分别代表两个不同方向的值.
  303. /*
  304. * Event types
  305. */
  306.  
  307. #define EV_SYN 0x00
  308. #define EV_KEY 0x01 //按键
  309. #define EV_REL 0x02 //相对坐标(轨迹球)
  310. #define EV_ABS 0x03 //绝对坐标
  311. #define EV_MSC 0x04 //其他
  312. #define EV_SW 0x05
  313. #define EV_LED 0x11 //LED
  314. #define EV_SND 0x12//声音
  315. #define EV_REP 0x14//repeat
  316. #define EV_FF 0x15
  317. #define EV_PWR 0x16
  318. #define EV_FF_STATUS 0x17
  319. #define EV_MAX 0x1f
  320. #define EV_CNT (EV_MAX+1)
  321.  
  322. 下面是一个模拟鼠标和键盘输入的例子:
  323.  
  324. #include <string.h>
  325. #include <stdio.h>
  326. #include <sys/types.h>
  327. #include <sys/stat.h>
  328. #include <fcntl.h>
  329. #include <linux/input.h>
  330. #include <linux/uinput.h>
  331. #include <stdio.h>
  332. #include <sys/time.h>
  333. #include <sys/types.h>
  334. #include <unistd.h>
  335.  
  336. void simulate_key(int fd,int kval)
  337. {
  338. struct input_event event;
  339. event.type = EV_KEY;
  340. event.value = ;
  341. event.code = kval;
  342.  
  343. gettimeofday(&event.time,);
  344. write(fd,&event,sizeof(event)) ;
  345.  
  346. event.type = EV_SYN;
  347. event.code = SYN_REPORT;
  348. event.value = ;
  349. write(fd, &event, sizeof(event));
  350. memset(&event, , sizeof(event));
  351. gettimeofday(&event.time, NULL);
  352. event.type = EV_KEY;
  353. event.code = kval;
  354. event.value = ;
  355. write(fd, &event, sizeof(event));
  356. event.type = EV_SYN;
  357. event.code = SYN_REPORT;
  358. event.value = ;
  359. write(fd, &event, sizeof(event));
  360.  
  361. }
  362.  
  363. void simulate_mouse(int fd)
  364. {
  365. struct input_event event;
  366. memset(&event, , sizeof(event));
  367. gettimeofday(&event.time, NULL);
  368. event.type = EV_REL;
  369. event.code = REL_X;
  370. event.value = ;
  371. write(fd, &event, sizeof(event));
  372.  
  373. event.type = EV_REL;
  374. event.code = REL_Y;
  375. event.value = ;
  376. write(fd, &event, sizeof(event));
  377.  
  378. event.type = EV_SYN;
  379. event.code = SYN_REPORT;
  380. event.value = ;
  381. write(fd, &event, sizeof(event));
  382. }
  383.  
  384. int main()
  385. {
  386. int fd_kbd;
  387. int fd_mouse;
  388. fd_kbd = open("/dev/input/event1",O_RDWR);
  389. if(fd_kbd<=){
  390. printf("error open keyboard:\n");
  391. return -;
  392.  
  393. }
  394.  
  395. fd_mouse = open("/dev/input/event2",O_RDWR);
  396. if(fd_mouse<=){
  397. printf("error open mouse\n");
  398. return -;
  399. }
  400.  
  401. int i = ;
  402. for(i=; i< ; i++)
  403. {
  404. simulate_key(fd_kbd, KEY_A + i);
  405. simulate_mouse(fd_mouse);
  406. sleep();
  407. }
  408.  
  409. close(fd_kbd);
  410. }
  411. 模拟了鼠标和键盘的输入事件。
  412. 关于这里 open 哪个 event 可以通过 cat /proc/bus/input/devices
  413. I: Bus= Vendor= Product= Version=
  414. N: Name="Macintosh mouse button emulation"
  415. P: Phys=
  416. S: Sysfs=/class/input/input0
  417. U: Uniq=
  418. H: Handlers=mouse0 event0
  419. B: EV=
  420. B: KEY=
  421. B: REL=
  422.  
  423. I: Bus= Vendor= Product= Version=ab41
  424. N: Name="AT Translated Set 2 keyboard"
  425. P: Phys=isa0060/serio0/input0
  426. S: Sysfs=/class/input/input1
  427. U: Uniq=
  428. H: Handlers=kbd event1
  429. B: EV=
  430. B: KEY= f800d001 feffffdf ffefffff ffffffff fffffffe
  431. B: MSC=
  432. B: LED=
  433.  
  434. I: Bus= Vendor= Product= Version=
  435. N: Name="Power Button (FF)"
  436. P: Phys=LNXPWRBN/button/input0
  437. S: Sysfs=/class/input/input3
  438. U: Uniq=
  439. H: Handlers=kbd event3
  440. B: EV=
  441. B: KEY=
  442.  
  443. I: Bus= Vendor= Product= Version=
  444. N: Name="Power Button (CM)"
  445. P: Phys=PNP0C0C/button/input0
  446. S: Sysfs=/class/input/input4
  447. U: Uniq=
  448. H: Handlers=kbd event4
  449. B: EV=
  450. B: KEY=
  451.  
  452. I: Bus= Vendor=046d Product=c018 Version=
  453. N: Name="Logitech USB Optical Mouse"
  454. P: Phys=usb-::1d.-/input0
  455. S: Sysfs=/class/input/input24
  456. U: Uniq=
  457. H: Handlers=mouse1 event2
  458. B: EV=
  459. B: KEY=
  460. B: REL=
  461.  
  462. 我的鼠标是 罗技 Logitech USB Optical Mouse 所以 鼠标是 event2
  463. 下面是一个读取 鼠标和键盘事件的例子:
  464. #include <stdio.h>
  465. #include <stdlib.h>
  466. #include <linux/input.h>
  467. #include <sys/types.h>
  468. #include <sys/stat.h>
  469. #include <fcntl.h>
  470. #include <unistd.h>
  471. #include <errno.h>
  472.  
  473. static void show_event(struct input_event* event)
  474. {
  475. printf("%d %d %d\n", event->type, event->code, event->value);
  476.  
  477. return;
  478. }
  479.  
  480. int main(int argc, char* argv[])
  481. {
  482. struct input_event event = {{}, };
  483. const char* file_name = argc == ? argv[] : "/dev/input/event2";
  484.  
  485. int fd = open(file_name, O_RDWR);
  486.  
  487. if(fd > )
  488. {
  489.  
  490. while()
  491. {
  492. int ret = read(fd, &event, sizeof(event));
  493. if(ret == sizeof(event))
  494. {
  495. show_event(&event);
  496. }
  497. else
  498. {
  499. break;
  500. }
  501. }
  502. close(fd);
  503. }
  504.  
  505. return ;
  506. }
  507.  
  508. 很多人对于 如何模拟 CTRL + SPACE 感兴趣, 下面也给个例子,呵呵。
  509. void simulate_ctrl_space(int fd)
  510. {
  511. struct input_event event;
  512.  
  513. //先发送一个 CTRL 按下去的事件。
  514. event.type = EV_KEY;
  515. event.value = ;
  516. event.code = KEY_LEFTCTRL;
  517. gettimeofday(&event.time,);
  518. write(fd,&event,sizeof(event)) ;
  519.  
  520. event.type = EV_SYN;
  521. event.code = SYN_REPORT;
  522. event.value = ;
  523. write(fd, &event, sizeof(event));
  524.  
  525. //先发送一个 SPACE 按下去的事件。
  526. event.type = EV_KEY;
  527. event.value = ;
  528. event.code = KEY_SPACE;
  529. gettimeofday(&event.time,);
  530. write(fd,&event,sizeof(event)) ;
  531.  
  532. //发送一个 释放 SPACE 的事件
  533. memset(&event, , sizeof(event));
  534. gettimeofday(&event.time, NULL);
  535. event.type = EV_KEY;
  536. event.code = KEY_SPACE;
  537. event.value = ;
  538. write(fd, &event, sizeof(event));
  539.  
  540. event.type = EV_SYN;
  541. event.code = SYN_REPORT;
  542. event.value = ;
  543. write(fd, &event, sizeof(event));
  544.  
  545. //发送一个 释放 CTRL 的事件
  546. memset(&event, , sizeof(event));
  547. gettimeofday(&event.time, NULL);
  548. event.type = EV_KEY;
  549. event.code = KEY_LEFTCTRL;
  550. event.value = ;
  551. write(fd, &event, sizeof(event));
  552.  
  553. event.type = EV_SYN;
  554. event.code = SYN_REPORT;
  555. event.value = ;
  556. write(fd, &event, sizeof(event));
  557.  
  558. }

linux下如何模拟按键输入和模拟鼠标【转】的更多相关文章

  1. adb命令模拟按键输入keycode

    adb命令模拟按键输入keycode 2017年05月18日 14:57:32 阅读数:1883 例子: //这条命令相当于按了设备的Backkey键 adb shell input keyevent ...

  2. adb shell命令模拟按键/输入input使用keycode 列表详解

    在adb shell里有一个非常使用的命令,模拟按键输入,这里首先不要理解为是键盘的模拟按键,下面命令的使用和键值做一个详解. input命令格式 adb shell input keyevent & ...

  3. 完美解决 Linux 下 Sublime Text 中文输入

    首先,我参考了好几篇文章,都是蛮不错的,先列出来: sublime-text-imfix:首先推荐这个方法,最简单,但是在我的系统上有些问题.可用这个的强烈推荐用这个 完美解决 Linux 下 Sub ...

  4. Python脚本控制的WebDriver 常用操作 <十二> send_keys模拟按键输入

    下面将使用WebDriver中的send_keys来模拟键盘按键输入 测试用例场景 send_keys方法可以模拟一些组合键操作: ctrl+a ctrl+c ctrl+v 等. 另外有时候我们需要在 ...

  5. 前端坑多:使用js模拟按键输入的踩坑记录

    坑 一开始在Google搜索了一番,找到了用jQuery的方案,代码量很少,看起来很美好很不错,结果,根本没用-- 我反复试了这几个版本: var e = $.Event('keyup') e.key ...

  6. adb 常用命令大全(6)- 模拟按键输入

    语法格式 input [<source>] <command> [<arg>...] 物理键 # 电源键 adb shell input keyevent 26 # ...

  7. linux下将终端的输入存入文件中

    代码很简单: #include <stdlib.h> #include <fcntl.h> #include <stdio.h> #include <unis ...

  8. Linux下sublime的中文输入问题

    比较久了,今天找到了解决方案: git clone https://github.com/lyfeyaj/sublime-text-imfix.git cd sublime-text-imfix &a ...

  9. ADB——模拟手机按键输入

    基本命令 adb 模拟按键输入的命令主要通过 input 进行 Usage: input [<source>] <command> [<arg>...] The s ...

随机推荐

  1. php插入中文数据到MySQL乱码

    事情是这样的:我在本地的测试成功了,放到服务器测试,发现服务器的数据库里的中文竟然乱码了. 我进行了以下几步基本的做法: PHP文件改为utf-8的格式. 加入header("Content ...

  2. Vue 和 angular

    vue适合移动端的项目,而angular更适合运用于Pc端的项目.

  3. Jmeter使用笔记之函数

    用Jmeter才做了一个项目的测试,就不得不对函数这部分吐槽一下,真是有点弱,难怪大多数人不用这个功能,不过如果用的好也是很方便的,以下慢慢说. 一.BeanShell函数 在测试中遇到了时间戳的加减 ...

  4. javascript extend

    interface Date{ addHours(h:number); addMinutes(m:number); format(str):string } interface String{ tri ...

  5. Delphi 之 菜单组件(TMainMenu)

    菜单组件TMainMenu 创建菜单双击TmenuMain,单击Caption就可以添加一个菜单项 菜单中添加分割线只需加“-”就可以添加一个分割线 级联菜单的设计 单击鼠标右键弹出菜单中选择Crea ...

  6. MyBatis关联查询,一对一关联查询

    数据库E-R关系 实体类 public class City { Long id; String name; Long countryId; Date lastUpdate; } public cla ...

  7. spring中的传播性 个人认为就是对方法的设置 其作用能传播到里面包含的方法上

    spring中的传播性 个人认为就是对方法的设置 其作用能传播到里面包含的方法上

  8. 51nod 1476 括号序列的最小代价(贪心+优先队列)

    题意 我们这有一种仅由"(",")"和"?"组成的括号序列,你必须将"?"替换成括号,从而得到一个合法的括号序列. 对于 ...

  9. OI回忆录第一章 逐梦之始

    2013年春,初中零年级.GXZ来到吉大高中机房,参加一位老师曾在班级宣传的"计算机培训".同行的有这位老师,以及近80名同学.和同学们一样,GXZ也是为了在机房玩游戏而参加所谓的 ...

  10. linux命令行打包、压缩及解压缩

    使用命令: tar 打包: tar -zcvf  目标文件 源文件或文件夹 目标文件为要打包成的文件的文件名, 打包后文件的 格式取决于目标文件的后缀名 单文件或文件夹打包 tar -zcvf ind ...