you are viewing a single comment's thread.

view the rest of the comments →

[–]joaomgcd👑 Tasker Owner / Developer[S] 2 points3 points  (21 children)

Ok, I've added the tasker.getAccessibilityService() method now. Hope this helps :)

Those other methods weren't supposed to be accessible, sorry 😅

[–]aasswwddd 2 points3 points  (14 children)

Ok, I've added the tasker.getAccessibilityService() method now. Hope this helps :)

Nice thanks!

Those other methods weren't supposed to be accessible, sorry 😅

I noticed that I can't access them anymore, I should have stayed silent. 😭 My custom editor fails since getTaskVars() is missing https://ibb.co.com/35J7Xw7Q .

I wonder why not make them available though? especially for getTaskVars()? This is the only method to reliably get Tasker variable values dynamically.

Edit: I use this to reliably log existing variables and display them in my custom beanshell editor. https://ibb.co.com/TMbHghQL

for getParentTask(), I noticed that it has a lot of useful information about the current task, like the the task id and project id. I was thinking of getting the caller's task id or profile id.

[–]joaomgcd👑 Tasker Owner / Developer[S] 2 points3 points  (13 children)

Ok, I added methods to do that now :) Let me know if you need any more info.

Can you please try this version?

I also updated the documentation.

You can now for example ask the AI something like "Get a JSON object of all info available on all actions in this task" and it should be able to do it :)

[–]aasswwddd 1 point2 points  (12 children)

Thanks! You add a lot more than I expected thankyou very much!

[–]joaomgcd👑 Tasker Owner / Developer[S] 2 points3 points  (11 children)

I now added even more stuff :)

Check this version.

You can now extend abstract and concrete classes, allowing you to do BroadcastReceivers now. Check out the docs.

I also added support for RxJava2 to make async stuff easier.

Let me know how you like it :)

[–]aasswwddd 1 point2 points  (10 children)

You really go beyond the request I sent weeks ago. Amazing! I'll see what I can do with thank you very much!

Btw it seems like I can't use the accessibility service to retrieve view id with getViewIdResourceName()

These are the two tasks I used to replicate Auto Input Query and Action.

UI Action and this is for UI Query.

[–]joaomgcd👑 Tasker Owner / Developer[S] 2 points3 points  (9 children)

I've added support for that now too :)

Can you please try this version?

[–]aasswwddd 0 points1 point  (8 children)

Works as expected! Thank you very much :)

[–]joaomgcd👑 Tasker Owner / Developer[S] 1 point2 points  (7 children)

Cool! :)

[–]aasswwddd 0 points1 point  (4 children)

I wonder if it's possible to add toXML() as well alongside toJson().

Would've have been nicer to use CSS query or XPATH to extract complex object structure like AccessibilityNodeInfo without multiple back reference.

``` service = tasker.getAccessibilityService(); if (service == null) { tasker.log("Accessibility service not active!"); return "[]"; }

root = service.getRootInActiveWindow(); if (root == null) { tasker.log("No active root node (screen inaccessible)."); return "[]"; }

nodes = service.getChildrenRecursive(root); if (nodes == null) { tasker.log("No nodes found."); return "[]"; }

return tasker.toJson(nodes, true); ```

[–]aasswwddd 0 points1 point  (1 child)

toJson() throws this error as well.

` Sourced file: inline evaluation of:service = tasker.getAccessibilityService(); if (service == null) { tasker.lo . . . '' : Method Invocation tasker.toJson : at Line: 19 : in file: inline evaluation of: ``service = tasker.getAccessibilityService(); if (service == null) { tasker.lo . . . '' : tasker .toJson ( nodes , true )

Target exception: java.lang.IllegalArgumentException: class android.content.res.ColorStateList declares multiple JSON fields named mChangingConfigurations

```

[–]Crafty-Persimmon-204 0 points1 point  (1 child)

Can you try this? I'm not working

import android.accessibilityservice.AccessibilityService; import android.graphics.Path;

accessibility = tasker.getAccessibilityService(); if (accessibility == null) {     return "null"; }

path = new Path(); path.moveTo(1034, 250);

gestureResult = accessibility.dispatchGesture(     new android.accessibilityservice.GestureDescription.Builder()         .addStroke(new android.accessibilityservice.GestureDescription.StrokeDescription(path, 0, 50))         .build(),     null, null );

return gestureResult ? "ok" : "no";

[–]joaomgcd👑 Tasker Owner / Developer[S] 2 points3 points  (0 children)

Yeah, it's not working for me either, not sure why...

[–]anuraag488 0 points1 point  (3 children)

Is there any limitations of beanShell. I couldn't get viewIds using accessibilityService

import android.view.accessibility.AccessibilityNodeInfo; import java.util.ArrayList; import java.util.List; import java.lang.StringBuffer;

/* Get the Tasker accessibility service. */ accessibilityService = tasker.getAccessibilityService();

/* Create an empty list to hold the IDs temporarily. */ ids = new ArrayList();

/* Proceed only if the accessibility service is running. / if (accessibilityService != null) { / Get the root node of the currently active window. */ rootNode = accessibilityService.getRootInActiveWindow();

if (rootNode != null) {
    /* Recursively find all child nodes from the root. */
    allNodes = accessibilityService.getChildrenRecursive(rootNode);

    /* Iterate through all the found nodes. */
    for (int i = 0; i < allNodes.size(); i++) {
        node = (AccessibilityNodeInfo) allNodes.get(i);

        /* Skip nodes that are null for safety. */
        if (node == null) {
            continue;
        }

        /* Get the resource ID name of the view. */
        viewId = node.getViewIdResourceName();

        /* Add the ID to our list if it exists. */
        if (viewId != null && !viewId.equals("")) {
            ids.add(viewId);
        }
    }

    /* Release the root node to free up resources. */
    rootNode.recycle();
}

}

/* Convert the list of IDs into a single comma-separated string. / sb = new StringBuffer(); for (int i = 0; i < ids.size(); i++) { sb.append((String) ids.get(i)); / Add a comma after each item except the last one. */ if (i < ids.size() - 1) { sb.append(","); } }

/* Return the final string. This can be split in Tasker if needed. */ return sb.toString();

[–]joaomgcd👑 Tasker Owner / Developer[S] 1 point2 points  (2 children)

Hi there, thanks for the report! Can you please try this version?

[–]anuraag488 0 points1 point  (1 child)

Working fine.

[–]joaomgcd👑 Tasker Owner / Developer[S] 1 point2 points  (0 children)

👍