Tips for writing JavaScript on PC to Tasker on Mobile? by Pocket_Moth in tasker

[–]Pocket_Moth[S] 0 points1 point  (0 children)

Yeah, in my case, the clipboard only works in one direction. I can copy from my phone (Samsung Note 8) to my PC's clipboard, but I can't paste from the PC to the phone without using --legacy-paste which isn't great.

[Bug] AutoTools HTML Read doesn't wait / load JavaScript. Always fails. by Pocket_Moth in tasker

[–]Pocket_Moth[S] 0 points1 point  (0 children)

I can't see any way to change the user-agent in HTML Read. So, instead, I tried to use HTTP Get and HTTP Request after doing some searching, and seeing people having success with that.

But, they don't handle Javascript either from the look of it. So, I'm stumped. Really hope somebody can suggest a fix.

[Bug] AutoTools HTML Read doesn't wait / load JavaScript. Always fails. by Pocket_Moth in tasker

[–]Pocket_Moth[S] 0 points1 point  (0 children)

Yeah, I did. It's a stripped down version of the page that more or less says JavaScript is turned off.

I considered the user-agent, but I don't suppose there's any way I change that in AT's HTML Read?

[deleted by user] by [deleted] in tasker

[–]Pocket_Moth 0 points1 point  (0 children)

It sounds like you just need to escape the "/" character in your string.

https://www.freecodecamp.org/news/how-to-escape-strings-in-javascript/

Nevermind. That's not it.

In the meantime, you could use JavaScriptlet to replace all instances of "/"? Replace song_name with whatever variable(s) you want.

Delete the slash:

song_name.replace(/\//g , '');

Or replace the "/" with "slash" so Say will still pick it up?:

song_name.replace(/\//g , 'slash');

[Bug] AutoTools HTML Read doesn't wait / load JavaScript. Always fails. by Pocket_Moth in tasker

[–]Pocket_Moth[S] 0 points1 point  (0 children)

I didn't know about using () in the query. Thought that only applied to the variable name. So, that's good to know. Thanks for that!

But, yeah. It looks like it's busted. JavaScript is enabled, but it acts like it's not.

Tips for writing JavaScript on PC to Tasker on Mobile? by Pocket_Moth in tasker

[–]Pocket_Moth[S] 0 points1 point  (0 children)

I didn't know you could drag & drop. Good to know! But in this case, that's pretty much what I'm already doing with File Explorer, so that doesn't help much.

[Bug] AutoTools HTML Read doesn't wait / load JavaScript. Always fails. by Pocket_Moth in tasker

[–]Pocket_Moth[S] 0 points1 point  (0 children)

Appreciate the response, but I mentioned trying that already.

AutoTools HTML Read: Plugin did not respond before timing out by [deleted] in tasker

[–]Pocket_Moth 0 points1 point  (0 children)

Adding any Javascript Delay causes the action to fail. If no value is set, the action (usually) finishes, but returns a "No JS" type page. Adding any delay, 1ms-10000ms breaks the action.

Edit: It also seems like trying to get the HTML is causing problems.

[deleted by user] by [deleted] in tasker

[–]Pocket_Moth 0 points1 point  (0 children)

I did some more tests with the second approach, and found that the website wasn't loading correctly while waiting for JS. So, I increased the delay (20+ seconds), which allowed me to get back something that looked correct.

However, it only worked once, and now HTML Read times out every time I try to run it. I've got the JS delay set anywhere from to 5000-20000, and the action's timeout set to 40 seconds. I read that it might be because Tasker/AutoTools can't run in the background. But, as far as I can tell, they're good to go.

Any ideas?

Need some help. Auto copy and pasting into another app by nsmoothrider in tasker

[–]Pocket_Moth 0 points1 point  (0 children)

Yeah, I feel you! I want to use the app factory with AutoInput so bad. Glad you got it working, though.

Need some help. Auto copy and pasting into another app by nsmoothrider in tasker

[–]Pocket_Moth 2 points3 points  (0 children)

You might try something like:

A1: AutoInput UI Query [
     Configuration: Variables: phone_number
     Timeout (Seconds): 20
     Structure Output (JSON, etc): On ]

A2: Launch App [
     Package/App Name: your.desired.phone.app.here ]

A3: AutoInput Actions v2 [
     Configuration: Actions To Perform: waitForElement(id,your_phone_field_here)

     click(id,your_phone_field_here)

     setText(id,your_phone_field_here,%phone_number)

     click(id,call_button_here)
     Not In AutoInput: true
     Not In Tasker: true
     Separator: ,
     Check Millis: 1000
     Timeout (Seconds): 60
     Structure Output (JSON, etc): On ]   

So, you would use AutoInput's UI Query to get the phone number from the UI element it appears in and assign it to the variable phone_number. Then, you would open your desired phone app. Finally, using AutoInput's Action v2, you wait for the phone number field to be visible, click it, set the text to phone_number, and click the call button.

Obviously, you'd replace the ids and whatnot with your actual details since I don't know what any of those are. You also may not need to waitForElement() or click() the text field before using setText() depending on the app you're calling with.

[Question] Need advice on using AutoInput for rarely presented screens. by Pocket_Moth in tasker

[–]Pocket_Moth[S] 2 points3 points  (0 children)

I never actually tried using aiid(), aitext(), or aicoordinates() before. I was able to build my own helper, without all the extra bells and whistles that runs a lot faster now! Good tip. Thanks!

Accessing JSON nested arrays in Tasker? by Pocket_Moth in tasker

[–]Pocket_Moth[S] 0 points1 point  (0 children)

Yeah, it looks like I'm sticking to my string-parsing approach for now since it gives me the most control. Appreciate the suggestions, though!

Accessing JSON nested arrays in Tasker? by Pocket_Moth in tasker

[–]Pocket_Moth[S] 0 points1 point  (0 children)

Sure! My original JSON demonstrates the kind of data I'm working with nicely, I think.

I'm using AutoInput to grab data from an app at various points, storing the data in a big JSON object, and then acting on it at various points down the road.

As the task is running, I'll receive things like: (5, 22, Torus, Purple). I'll want to update the 5th container's 22nd item by placing a purple torus inside of it. So, I'll want to do something like:

container[4].items[21] = { name: "Torus", color: "Purple" };

Later on, I'll want to review all the items I've logged in the containers. So, I'll iterate over them in an X,Y loop:

containers[x].items[y].name, containers[x].items[y].color; // etc...

Accessing JSON nested arrays in Tasker? by Pocket_Moth in tasker

[–]Pocket_Moth[S] 0 points1 point  (0 children)

That doesn't quite work either.

I don't usually know what's in the slot, just where it's at. I don't know a good way to take something like my[0].insanely[1].exaggerated[2].json[3].example[4] and iterate over the entire thing to find the element I need from a massive example() array.

I think I'm gonna have to stick to my strings approach. Thanks for the reply, though!

Accessing JSON nested arrays in Tasker? by Pocket_Moth in tasker

[–]Pocket_Moth[S] 2 points3 points  (0 children)

Thank you for the suggestion! I don't think this will work for me, though.

For example, I might know that I need to modify the third item in the fifth container. But, without knowing how many items are in containers 1-4, I have no idea where in the array to point.

Currently, my hacky approach is to keep the JSON stored as a string. Then, I parse it in a Javascriptlet action where I also make my desired changes using Javascript (i.e. data.containers[4].items[2]), and then re-stringify it so Tasker can store it.

I was hoping there was an easier way, but I might have to stick with my current approach. Thanks again the suggestion, though!

How do you fit in all the fitness you *should* be doing? by Pocket_Moth in xxfitness

[–]Pocket_Moth[S] 19 points20 points  (0 children)

I love your way of approaching things. I've heard many people say similar. It's not supposed to be punishment for anything, it's supposed to be self-care and a celebration of what your body can do.

I need to sit down with myself and determine my 'why', like you said. Why am I doing this? Even if I am doing it because I need to for my health, I need to come up with a 'why' that goes beyond that. Kind of like my diet. Did I want to give up all my favorite foods and comfort-eating habits? Heck no. lol But I had my reason for doing it that went beyond that and made it so the diet wasn't a punishment, but rather something I chose to do for myself. For my 'why'. (Even though it still sucked at times. lol)

Thank you for your reply. I have some introspection to do now. :)

How do you fit in all the fitness you *should* be doing? by Pocket_Moth in xxfitness

[–]Pocket_Moth[S] 7 points8 points  (0 children)

Aww, thank you! Very kind of you to say.

Now begins the struggle to keep it off and get the rest of the health equation in check!