AutoInput Multiple x,y coordinate search , same screen cap

Discussion in 'AutoApps' started by Exilereven, Aug 15, 2016.

  1. Exilereven

    Exilereven New Member

    Joined:
    Aug 15, 2016
    Messages:
    23
    Likes Received:
    0
    I've figured out how to use AI to get correct pixel color for me, then I compare it to a predefined variable hexcolor. So it will do something if they match.

    What I'm wanting to do now is be able to check multiple x,y coordinates for the same color from the same single screen capture, so as not to have to re screen cap every single time for each area each time (which would take forever for about 16 different coordinates.
    Is there anyway to accomplish this with AI and tasker? Like, are there any commands in the pixel color window I can input when using AI screencap to check for multiple pixels like this: 1020,190;1120,190;1220,190. So I can check different areas on the screen all in one single go of one screen cap.
     
  2. Exilereven

    Exilereven New Member

    Joined:
    Aug 15, 2016
    Messages:
    23
    Likes Received:
    0
    Does anyone even look at these forums? If this is not the spot. Please please without sounding offensive, point me in the correct direction. I just wanna know where to go that someone doesn't respond half a year later, I need real human beings that frequent to get my answer.
     
  3. Robert Ryan

    Robert Ryan Member

    Joined:
    Mar 9, 2015
    Messages:
    52
    Likes Received:
    4
    I am here fairly often, but I don't have any experience with the Screen Capture action.

    You could try the Tasker forum on Google Groups (15,000 members) or /r/tasker on reddit (25,000 members). There is also a forum on Google+.

    There are a little over 1000 members registered on the AutoApps forum, but only a small percentage are actually active. Joao, the developer, is apparently on summer break.

    Sent from my XT1585 using Tapatalk
     
  4. Exilereven

    Exilereven New Member

    Joined:
    Aug 15, 2016
    Messages:
    23
    Likes Received:
    0
    Thank you for replying. I'm not sure if someone or you can help me or not. My only last standing issue is trying to interpret when a certain item is in a certain slot in my inventory. I can already do it.....but, it is very very slow if I want to do seperate areas of pixels for each color of hex I'm looking for.
     
  5. easiuser

    easiuser Member

    Joined:
    Mar 7, 2015
    Messages:
    50
    Likes Received:
    4
    If you are rooted, the following Tasker task will get the pixel color from a screen capture.
    You could separate out the screen capture and put the file parsing part in a loop and possibly optimize for your purposes.

    Of course it would be better if Joao could give you the option you are seeking.

    Pixel By Color (397)
    A1: Variable Set [ Name:%devicewidth To:1440 Do Maths:Off Append:Off ]
    A2: Variable Set [ Name:%par1 To:100 Do Maths:Off Append:Off ] If [ %par1 !Set ]
    A3: Variable Set [ Name:%par2 To:100 Do Maths:Off Append:Off ] If [ %par2 !Set ]
    A4: Variable Set [ Name:%offset To:%devicewidth * %par2 + %par1 + 3 Do Maths:On Append:Off ]
    A5: Run Shell [ Command:su -cn u:r:system_app:s0
    screencap /sdcard/scr.dump; let offset=%offset; stringZ=$(dd if='/sdcard/scr.dump' bs=4 count=1 skip=$offset 2>/sdcard/result.txt| hd); red=$(echo $stringZ | cut -d' ' -f2 | tail -c3); green=$(echo $stringZ | cut -d' ' -f3 | tail -c3); blue=$(echo $stringZ | cut -d' ' -f4 | tail -c3); rgb="$red$green$blue"; echo $rgb; Timeout (Seconds):20 Use Root:On Store Output In:%final Store Errors In: Store Result In: ]
    A6: Return [ Value:%final Stop:On ]
     
    Exilereven likes this.
  6. Exilereven

    Exilereven New Member

    Joined:
    Aug 15, 2016
    Messages:
    23
    Likes Received:
    0
    My only question is how do you know what resolution you put in for the screen cap. My developer thing says one thing, but when I check my screen most programs are saying it's 720, instead of 1080 like my developer options says. How so you specifically use that code lol.
     
  7. Exilereven

    Exilereven New Member

    Joined:
    Aug 15, 2016
    Messages:
    23
    Likes Received:
    0
    Thank you, btw
     
  8. Robert Ryan

    Robert Ryan Member

    Joined:
    Mar 9, 2015
    Messages:
    52
    Likes Received:
    4
    Have you tried to take the screen shot cropped to the single pixel that you need? That seems much faster than doing the whole screen each time.

    Test (78)

    A1: AutoInput Screen Capture [
    Configuration:Screenshot
    Path: /storage/emulated/0/AutoInput/screenshot.png
    Crop : 500,500,1,1
    Pixel Color : 0,0
    Palette: false
    Get Average Color : false
    Timeout (Seconds):200 ]

    A2: Flash [
    Text:%aiscreenshotpixelcolor
    Long:Off ]


    Sent from my XT1585 using Tapatalk
     
  9. Exilereven

    Exilereven New Member

    Joined:
    Aug 15, 2016
    Messages:
    23
    Likes Received:
    0
    N
    I have not tried that yet, gonna try this morning when I catch a min.
     
  10. easiuser

    easiuser Member

    Joined:
    Mar 7, 2015
    Messages:
    50
    Likes Received:
    4
    I use this infrequently and with just a few devices so I have not researched how to automatically obtain this information. I have typically matched the resolution obtained by checking the show pointer location (under developer options).
    I think there are some shell command like dumpsys that will spit it out, but I haven't tried.
     
  11. Robert Ryan

    Robert Ryan Member

    Joined:
    Mar 9, 2015
    Messages:
    52
    Likes Received:
    4
    You can get display metrics via Java, if that's what you mean:

    Test DIP (20)

    A1: Java Function [
    Return:res
    Class Or Object:CONTEXT
    Function:getResources
    {Resources} () ]

    A2: Java Function [
    Return:dis_met
    Class Or Object:res
    Function:getDisplayMetrics
    {DisplayMetrics} () ]

    A3: Java Function [
    Return:%dis_met
    Class Or Object:dis_met
    Function:assign
    {DisplayMetrics} () ]

    A4: Flash [
    Text:%dis_met
    Long:Off ]

    A5: Java Function [
    Return:%dis
    Class Or Object:dis_met.scaledDensity
    Function:assign
    {DisplayMetrics} () ]

    A6: Flash [
    Text:%dis
    Long:Off ]


    Sent from my XT1585 using Tapatalk
     
  12. Exilereven

    Exilereven New Member

    Joined:
    Aug 15, 2016
    Messages:
    23
    Likes Received:
    0
    Thank you so much for the code. But, I need a little bit of detail and I think I can make it work. What are you using at %par1 and %par2 when you call it later with perform task. Just a little advice on how tovuse it would be amazing, please and thank you.

    Ok, so I did a little testing. I got it to work whenever I run your code by itself. But it only returns %final instead of a hex color when I try and run it from another task using Perform Task. Any suggestions?
     
    Last edited: Aug 17, 2016
  13. easiuser

    easiuser Member

    Joined:
    Mar 7, 2015
    Messages:
    50
    Likes Received:
    4
    %par1 is the x location and %par2 is the y location. Steps A2 and A3 set them to 100 & 100 if they are initially empty.

    %final gets the red green blue hex values of the x,y coordinates in the form XXYYZZ and is returned to the calling routine.
     
  14. Exilereven

    Exilereven New Member

    Joined:
    Aug 15, 2016
    Messages:
    23
    Likes Received:
    0
    E
    Erything works perfect, except when I try and call the pixel color task using Perform Task from a different task, it only sends back %final, instead of the hexcode, like it does when ran by itself. Any suggestions? Maybe different way of calling it?
     
  15. easiuser

    easiuser Member

    Joined:
    Mar 7, 2015
    Messages:
    50
    Likes Received:
    4
    First make sure the file /sdcard/scr.dump is created. If not, screencap is not working.
    It can also happen when you don't have some of the string manipulating functions like cut and tail installed.

    You might have to install busybox or equivalent. You can also try pasting the command in a terminal window to see if you receive any additional responses from the shell.
     
  16. Exilereven

    Exilereven New Member

    Joined:
    Aug 15, 2016
    Messages:
    23
    Likes Received:
    0
    I do have busy box installed. It returns the hex value of the color perfect when I run the task by itself. The problem is trying to call that same task from another task using Perform task. Returns the variable name literally %final, instead the pixel color hexcode like it does when ran by itself.
     
  17. easiuser

    easiuser Member

    Joined:
    Mar 7, 2015
    Messages:
    50
    Likes Received:
    4
    Probably a priority issue and the . Here is a call that returns and flashes the correct value.

    TestPixel (488)
    A1: Perform Task [ Name:pixel By Color Priority:%priority Parameter 1 (%par1):120 Parameter 2 (%par2):200 Return Value Variable:%color Stop:Off ]
    A2: Flash [ Text:%color Long:Off ]

    Excuse the above. A colon-P turned into emoticon. LOL
     
  18. Robert Ryan

    Robert Ryan Member

    Joined:
    Mar 9, 2015
    Messages:
    52
    Likes Received:
    4
    Shouldn't Priority be set to %priority+1 to ensure the called task finishes before the main task continues?

    Sent from my XT1585 using Tapatalk
     
  19. easiuser

    easiuser Member

    Joined:
    Mar 7, 2015
    Messages:
    50
    Likes Received:
    4
    Can't hurt. Userguide states that if the child task is the same or greater than the current task it will finish before the current task. In any event it does work on my phone.

    Have you taken a look at the run log?
     
  20. Robert Ryan

    Robert Ryan Member

    Joined:
    Mar 9, 2015
    Messages:
    52
    Likes Received:
    4
    Hmm, under Flow Control in the UG it states:

    Subroutines

    To call another task, use the Perform Task action. To use it as a subroutine, you just need to ensure that the priority of the calling task is less than the priority of the called task

    Am I reading that wrong?

    Sent from my XT1585 using Tapatalk
     

Share This Page