Skip to main content

A pure Python module for recording and processing low-level Android input events (Mouse/Keyboard/Touchpad) - no dependencies

Project description

A pure Python module for recording and processing low-level Android input events (Mouse/Keyboard/Touchpad) - no dependencies

pip install geteventplayback

Tested against Windows 10 / Python 3.11 / Anaconda

GeteventPlayBack is a powerful Python module that simplifies the capture and processing of input events from Android devices, including not only touch events but also mouse and keyboard events. It is designed to work entirely with native Python, making it a versatile choice for Android input event analysis.

IMPORTANT: ONLY WORKS ON ROOTED DEVICES/EMULATORS

YT https://www.youtube.com/watch?v=LyGX7rQ-fLY

"""
Args:
	adb_path (str): The path to the 'adb' tool.
	device (str): The device event file to record, e.g., "/dev/input/event3".
	device_serial (str): The serial number or address of the Android device.
	print_output (bool): Whether to print the 'getevent' output to the console.
	tmpfolder_device (str): The temporary folder on the device to store event data.
	tempfolder_hdd (str): The temporary folder on the local HDD to store event data.
	add_closing_command (bool): Whether to add closing commands to the event replay.
	clusterevents (int): The number of events to cluster together for replay, allowing
	you to adjust playback speed.

Methods:
	- start_recording(): Start recording input events, including mouse and keyboard events,
	  and customize the playback speed.
	- _get_files_and_cmd(unpacked_data): Process the recorded data and generate
	  commands for event replay.
	- _format_binary_data(): Format binary data from 'getevent' output into events.

Attributes:
	- alldata (list): The raw 'getevent' output data, stored as bytes.
	- FORMAT (str): The format string for parsing binary data.
	- chunk_size (int): The size of each event in bytes.
	- timestampnow (float): The current timestamp.
"""
	

import subprocess

from geteventplayback import GeteventPlayBack

pla = GeteventPlayBack(
    adb_path=r"C:\Android\android-sdk\platform-tools\adb.exe",
    device="/dev/input/event4",
    device_serial="127.0.0.1:5555",
    print_output=True,
    tmpfolder_device="/sdcard/event4/",
    tempfolder_hdd=rf"C:\sadxxxxxxxxxxxx",
    add_closing_command=True,
    clusterevents=16,
)

results = pla.start_recording()

subprocess.run(
    [pla.adb_path, "-s", pla.device_serial, "shell"],
    bufsize=0,
    input=results["adbcommand"],  # Can be resused
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geteventplayback-0.10.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

geteventplayback-0.10-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file geteventplayback-0.10.tar.gz.

File metadata

  • Download URL: geteventplayback-0.10.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for geteventplayback-0.10.tar.gz
Algorithm Hash digest
SHA256 b74d977e9860605348b5caba85ec44000756fba3a28d7d4aa326ee658287dbdb
MD5 5322dfd93d8f9b7b755dd73d12e56b57
BLAKE2b-256 1f886d8b9a088e921a35438beb01e0ccf7c19c0efba1a69aaa3e398d7cb57ec0

See more details on using hashes here.

File details

Details for the file geteventplayback-0.10-py3-none-any.whl.

File metadata

File hashes

Hashes for geteventplayback-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 27363bc40b25f564645d864a2386690800927fb6abeccfb70d2758eae786a4f7
MD5 19d950ea736875245a0c4b7b5c375171
BLAKE2b-256 f3c025712d00e3d3d817e717c601382503cfe839a2a3ed0bfc4c46cc079a92b7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page