X-SLAYER / flutter_accessibility_service

Flutter plugin for interacting with Accessibility Service in Android.
https://pub.dev/packages/flutter_accessibility_service
MIT License
37 stars 27 forks source link

stream doesn't always return #20

Open Triden opened 8 months ago

Triden commented 8 months ago

Hello, could you answer how to work with your package? For example, I want to get a specific element on the screen, but your stream doesn't always return all the elements. I go to the chrome page and only the text from the timer is returned. How can I return all the elements? I want to automate my work. For example, how to return not only changes, but also simply return the current elements?

Also, for example you don't have a click event as a percentage of the screen. You will have to create all this yourself

Triden commented 8 months ago

I'm ready to donate to you if you help me solve this issue.

tanzil114 commented 8 months ago

@Triden Hi, I am doing something similar. I missed one thing, maybe its the same for you. Have you tried getting the subnodes as well?

FlutterAccessibilityService.accessStream.listen((event) {
        _sendEvent(event, socket, deviceId);
        for (var n in event.subNodes ?? []) {
          _sendEvent(n, socket, deviceId, parentPackageName: event.packageName);
        }
      });
X-SLAYER commented 8 months ago

The stream already returns a node with the children that represent other elements of these subnodes so basically you can try to explore it and check the example that I already tried maybe you can achieve the result that you

tanzil114 commented 8 months ago

@X-SLAYER I am sending the events I am receiving from the stream to a socket server, so server can then decide to perform any action based on a certain event. The problem is I am not able to identify which event refers to what element in the screen, because the event which has the text doesn't have the click action available, and the element that does have click action, simply has 'null' in text. Can you please let me know how can I achieve this?

Triden commented 8 months ago

@Triden Hi, I am doing something similar. I missed one thing, maybe its the same for you. Have you tried getting the subnodes as well?

FlutterAccessibilityService.accessStream.listen((event) {
        _sendEvent(event, socket, deviceId);
        for (var n in event.subNodes ?? []) {
          _sendEvent(n, socket, deviceId, parentPackageName: event.packageName);
        }
      });

I wrote my own plugin that doesn't work through a thread. And it provides data upon request.

Triden commented 8 months ago

The stream already returns a node with the children that represent other elements of these subnodes so basically you can try to explore it and check the example that I already tried maybe you can achieve the result that you

Sorry, I also want to ask, are you by any chance going to add work with dispatchGesture?

I tried to add gestures and clicks. But they don't want to work for me.

fun clickAt(x: Int, y: Int): Boolean {
        val gestureBuilder = GestureDescription.Builder()
        val path = Path()
        path.moveTo(x.toFloat(), y.toFloat())
        gestureBuilder.addStroke(GestureDescription.StrokeDescription(path, 0, 1L))
        val gesture: GestureDescription = gestureBuilder.build()
        return dispatchGesture(gesture, object : GestureResultCallback() {
            override fun onCompleted(gestureDescription: GestureDescription) {
                Log.d("start", "+++++");
                super.onCompleted(gestureDescription)

            }

            override fun onCancelled(gestureDescription: GestureDescription) {
                Log.d("start", "-----");
                super.onCancelled(gestureDescription)

            }
        }, null)
    }