0

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:

    1. SDL input events (as received from SDL)
    1. scrcpy input events (this API)
    1. 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.

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134
  • The error you showed indicates you don't have https://github.com/dtmilano/CulebraTester2-public running and listening on port 9987. You can follow the instructions on that page or add another question here. – Diego Torres Milano Jul 03 '23 at 22:49
  • And yes, https://github.com/dtmilano/CulebraTester2-public would be another way of sending event without using `adb`. – Diego Torres Milano Jul 03 '23 at 22:49
  • @DiegoTorresMilano Thanks for your answer and for developing CulebraTester, I'm not used to sockets or networks in general so I'm so lost, If you could give some indications, I don't understand https://github.com/dtmilano/CulebraTester2-public#how-to-run-culebratester2- , I downloaded "app" and "instrumenation" but don't know how to use that. Can't run https://github.com/dtmilano/CulebraTester2-public#how-to-run-culebratester2- because "configuration" is not defined – ManoloPutoAmo Jul 04 '23 at 20:26
  • NP, once you downloaded app and instrumentation, install them on your device, and start the server `bash <(curl -sL https://git.io/JT5nc) start-server`. Once the server is running, your AndroidViewClient commands will use it as in the previous example (the one using `helper`). – Diego Torres Milano Jul 04 '23 at 23:07
  • I'm working in Windows, as far as I'm concerned "bash" is used in Linux, idk how to do same on Windows. – ManoloPutoAmo Jul 06 '23 at 01:30
  • Use `git-bash`: https://git-scm.com/download/win – Diego Torres Milano Jul 06 '23 at 04:10
  • Alternative if you checked out the source you can run `./culebratester2 start-server` instead which will required git-bash on windows as well, but not curl. – Diego Torres Milano Jul 06 '23 at 04:12
  • Thanks for your help and knowledge. I've finally done it. :) – ManoloPutoAmo Jul 16 '23 at 20:46

0 Answers0