1. Check out our companion app, Forums for Android! Download from Google Play

Support Speed up screenshot code

Discussion in 'Android Apps & Games' started by Exilereven, Nov 16, 2016.

  1. Exilereven

    Exilereven New Member
    Thread Starter
    15

    Jul 30, 2016
    2
    0
    15
    Male
    Hello, I have been searching all over the net trying to find a way to quickly get repetitive screencaps to pull pixel colors from. this is my tasker task I'm using to get the job done below.
    I'm wondering how I can improve performance of the piece as a whole, or at least speed up my screenshots, or figure out why my tasker coding skills may be sub par lol. if anyone has any ideas how to speed this up I would love any advice, please and thank you.

    Side note-it needs to stay root for the screencaps, because the app I'm getting them from doesn't like normal ones lol.


    Phone: galaxy note 3
    Android 5.0 lollipop

    This is the get pixel code I'm using, I call this with perform task so b I can get color at pixel.


    Pixel Color (6)
    A1: Variable Set [ Name:%devicewidth To:1080 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:%par2 * %devicewidth + %par1 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| hexdump);

    red=$(echo $stringZ | cut -d' ' -f2 | tail -c3);

    green=$(echo $stringZ | cut -d' ' -f2 | head -c2);

    blue=$(echo $stringZ | cut -d' ' -f3 | 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 ]


    This is the code I use in my main script. which I'm trying to get either to run faster, or point me in the right direction lol.

    Shell Top Works Perfect (11)
    A1: Variable Set [ Name:%attacking To:0 Do Maths:Off Append:Off ]
    <beginloop>
    A2: Anchor
    A3: Perform Task [ Name:pixel Color Priority:%priority + 1 Parameter 1 (%par1):730 Parameter 2 (%par2):907 Return Value Variable:%color Stop:Off ]
    A4: If [ %attacking ~ 2 ]
    A5: Stop [ With Error:Off Task: ]
    A6: Else If [ %attacking ~ 1 ]
    A7: Goto [ Type:Action Label Number:1 Label:still attacking top ]
    A8: End If
    <start attacking top>
    A9: If [ %color ~ #19ba4a | %color ~ #e6ff00 | %color ~ #efff00 | %color ~ #21ba4a &+ %attacking ~ 0 ]
    A10: Variable Set [ Name:%attacking To:1 Do Maths:Off Append:Off ]
    A11: Run Shell [ Command:input tap 960 400 Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
    A12: Goto [ Type:Action Label Number:1 Label:beginloop ]
    <still attacking top>
    A13: Else If [ %color ~ #19ba4a | %color ~ #e6ff00 | %color ~ #21ba4a | %color ~ #eeff00 &+ %attacking ~ 1 ]
    A14: Goto [ Type:Action Label Number:1 Label:beginloop ]
    <top is red>
    A15: Else If [ %color ~ #ce3531 | %color ~ #ce3131 ]
    A16: Run Shell [ Command:input tap 960 400 Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
    A17: Variable Set [ Name:%attacking To:2 Do Maths:Off Append:Off ]
    A18: Goto [ Type:Action Label Number:1 Label:beginloop ]
    A19: Else
    A20: Variable Set [ Name:%attacking To:2 Do Maths:Off Append:Off ]
    A21: Goto [ Type:Action Label Number:1 Label:beginloop ]
    A22: End If
     

    Advertisement

  2. Thom

    Thom  
    VIP Member
    1,243

    Feb 16, 2011
    11,524
    4,741
    1,243
    Male
    Software Developer
    Keene, NH USA
    Welcome to Android Forums.

    I am not root-ed so I can't help much. Maybe someone who is will step in.

    ... Thom
     

Share This Page

Loading...