I want to use sendevent command to simulate touch event, I followed this link, and it works.

Use getevent to record, then use sendevent to repeat them, code like below, it can tap position 540 1802.

  sendevent /dev/input/event1 3 57 0
  sendevent /dev/input/event1 3 53 540
  sendevent /dev/input/event1 3 54 1802
  sendevent /dev/input/event1 0 0 0
  sendevent /dev/input/event1 3 57 -1
  sendevent /dev/input/event1 0 0 0

There's only one problem, if device reboot, sendevent won't work, I have to use my finger to touch screen once, then it will work again.

How to let it work without any manually touch?

migrated from superuser.com Feb 24 at 18:11

This question came from our site for computer enthusiasts and power users.

  • It may be a certain flag like "user active" .. You may need to simulate a key input, or something to trigger the "user active" flag. – Zillinium Feb 24 at 22:34
  • I think your comment may be a reason, but do you know more details? I have no idea how to active device. No password is set on this device, it will go to launcher directly, I also tried to set password and enter password via input command, sendevent still won't work after unlocked. – user2735005 Feb 25 at 1:28
  • I'm not sure what would cause it other than some sort of User Active check... I can only think of a few ways programmatically that would work. .. Maybe the input hasn't been initiated yet and it requires a start of input prior to sending events to it... for adb I use input tap 540 1802... So full command would be adb shell input tap 540 1802 ... Maybe try this first before sending more events... Not sure. – Zillinium Feb 25 at 5:55
  • Even input tap first, sendevent still not work. OK, thanks anyway. – user2735005 Feb 26 at 3:57
  • I can't find anything relating to this issue, it may be device specific. – Zillinium Feb 26 at 4:55

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.