Skip to main content

Send touch/longtouch events to BlueStacks/Android

$pip install sendevent-touch



from sendevent_touch import SendEventTouch



sendtouch = SendEventTouch(

    adb_path="C:\\Users\\Gamer\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe",

    deviceserial="localhost:5735",

    sdcard="/storage/emulated/0/",  # it is probably better to pass the path, not the symlink

    tmp_folder_on_sd_card="AUTOMAT",  # if the folder doesn't exist, it will be created

    bluestacks_divider=32767,

    use_bluestacks_coordinates=True,  # Recalculates the BlueStacks coordinates https://stackoverflow.com/a/73733261/15096247

)



sendtouch.connect_to_adb()



# Useful if you want to repeat the click

df_click1 = sendtouch.get_dataframe_for_clicks(50, 50)

sendtouch.touch_df(

    df_click1, struct_folder="struct real"

)  # "struct real" will use the recalculated coordinates for BlueStacks





# Touching without returning a DataFrame

sendtouch.touch(520, 40, struct_folder="struct real")





# Same thing for longtouch, duration is in seconds

sendtouch.longtouch_df(df_click1, duration=2.5, struct_folder="struct real")

sendtouch.longtouch(520, 40, duration=3.1, struct_folder="struct real")





# Using struct_folder="struct" should work for any rooted Android device, but I haven't checked it!

# I would be grateful for any feedback!

df_click1 = sendtouch.get_dataframe_for_clicks(50, 50)

sendtouch.touch_df(df_click1, struct_folder="struct")

sendtouch.touch(520, 40, struct_folder="struct")





sendtouch.longtouch_df(df_click1, duration=2, struct_folder="struct")

sendtouch.longtouch(520, 40, duration=3, struct_folder="struct")



#%timeit sendtouch.touch_df(df_click1 ,struct_folder="struct real")

# 109 ms ± 4.62 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)

#%timeit subprocess.run('adb shell input tap 50 50')

# 197 ms ± 1.54 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)

Tested against Windows 10 / Python 3.9.13 / BlueStacks 5

It should also work with any rooted Android device, the only problem might be the "bluestacks_divider".

https://stackoverflow.com/a/73733261/15096247

But changing the code (if necessary) shouldn't be a big thing.

Since my cell phone is not rooted, and I have no intention of rooting it, I cannot test the module against a physical Android device. (I would be grateful for any feedback)

Metadata

Release files for sendevent-touch 0.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sendevent-touch 0.11
File Size Uploaded Provenance Actions
sendevent_touch-0.11.tar.gz 8.0 kB Without provenance Details for sendevent_touch-0.11.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sendevent-touch 0.11
File Interpreter ABI Platform Actions
sendevent_touch-0.11-py3-none-any.whl Python 3 none any Details for sendevent_touch-0.11-py3-none-any.whl

Total release size: 17.5 kB

Release files / sendevent_touch-0.11.tar.gz

Download URL sendevent_touch-0.11.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2a53e909903b197133b1abc8f3a1b0b0603a70406c487d309cf136d3cbe93cea
BLAKE2b-256 checksum
How to use checksums
10c7f903484225d96c4e986c05d0d6ecf731b1468a01d5312d007a0e061d1815
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / sendevent_touch-0.11-py3-none-any.whl

Download URL sendevent_touch-0.11-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7536f1e103e136bccc16972931becc4713e1183e0504f69bf02141242e03e6ee
BLAKE2b-256 checksum
How to use checksums
3ce3ebc51399cf69ab4a1ca7a651c316eb843767b4552eb8eb8dd386f350faba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Security for sendevent-touch 0.11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.11 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page