I'm making a script in Python that simulates taps in my device's screen, I use ADB usually but with a game (Clash of Clans), ADB commands doesn't work, I assume that has some anticheat, with screen mirroing using Scrcpy mouse inputs works fine, this is how inputs works in Scrcpy_inputs_events.h
In practice, there are 3 levels of input events:
-
- SDL input events (as received from SDL)
-
- scrcpy input events (this API)
-
- the key/mouse processors input events (Android API or HID events)
I want to know is there is a way to do the same with Python, cause I've tried some things but all of thems seems to use ADB. My device is rooted if its helps.
I used adb throught cmd ("adb shell input tap x y"), I've also tried using "swipe" instead of "tap". I'm currently using AndroidViewClient to make screenshots, so tried with touch function of it, but didn't work or maybe I'm not using it corretly :
device, serialno = ViewClient.connectToDeviceOrExit()
device.touch(137, 1000)
That doesn't raise error, but when I try:
from com.dtmilano.android.viewclient import ViewClient
from culebratester_client.models import Point # I know this is not used on the script
helper = ViewClient(
*ViewClient.connectToDeviceOrExit(), useuiautomatorhelper=True
).uiAutomatorHelper
helper.ui_device.touch(137, 1000)
It raises this:
CulebraTester2 server should have been started and localport 9987 redirected to remote port 9987. 2023-06-29 14:00:22,648 WARNING Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000024F75A0E1D0>: Failed to establish a new connection: [WinError 10061] A connection cannot be established since the destination computer expressly denied the connection')': /v2/uiDevice/dumpWindowHierarchy?format=JSON
I can't use JPython because my code is python3 not python2.