Task Killer with Tasker

404 views
Skip to first unread message

francwalter

unread,
Oct 16, 2015, 7:15:28 PM10/16/15
to Tasker
Hello

I plan to create a simple Task Killer with Tasker.

I do a Run Shell (with root) action:
ps | grep u0_ | awk '{print $9 "#"}'
and with Variable split (with #) of the output I get all running task names.
With the command:
am force-stop %outputX
(where X is the number of task I want to kill)
I can immediately kill that process.

Now I have a main problem:
To chose the task I want to kill, I need a scene with a button for each running task.
I could do it with a normal scene and fill this up with command buttons, which I label as the running task and kill with them each task.
But on my SGS4 I found around 45 process running.
I cannot put 50 command buttons there, maybe the half unused.
I need a WebView with dynamic JavaScript I guess. To be able to scroll down, to be able to fill only the needed amount of buttons to the view, not the maximum. A javascript which creates on Create Scene each button dynamically etc.

So my question is: is it principally possible to create on run time a scene with WebView which I fill dynamically with my found processes?
Then with this WebView, with html-buttons is it possible to give it back to the Task and fill the am force-stop action to kill individually a process?

Or is that not like this possible?
Or is there other maybe better ways instead of WebView and Javascript?

Thank's
franc

Rich D

unread,
Oct 16, 2015, 7:31:54 PM10/16/15
to Tasker Google Groups Post

> To chose the task I want to kill, I need a scene with a button for each running task.
> I could do it with a normal scene and fill this up with command buttons, which I label as the running task and kill with them each task.

> Or is there other maybe better ways instead of WebView and Javascript?

A simple menu element in the scene will put the names in a scrollable menu and a tap on the menu item will give you the name in the local variable %tap_label

You can use a comma separated variable or a variable array to populate the menu.

francwalter

unread,
Oct 17, 2015, 5:09:31 PM10/17/15
to Tasker

This was the thing! A menu.
Thank for this hint.

Now this work like this. I have a task and a scene both named TaskKill

The task:

Taskkill (169)
A1: Run Shell [ Command:ps | grep u0_ | awk '{print $9 "#"}' Timeout (Seconds):0 Use Root:On Store Output In:%output Store Errors In: Store Result In: ]
A2: Variable Search Replace [ Variable:%output Search:\s Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A3: Variable Split [ Name:%output Splitter:# Delete Base:Off ]
A4: Show Scene [ Name:TaskKill Display As:Dialog Horizontal Position:100 Vertical Position:100 Animation:System Show Exit Button:Off Continue Task Immediately:Off ]
A5: If [ %process Set ]
A6: Variable Search Replace [ Variable:%process Search::.* Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A7: Run Shell [ Command:am force-stop %process Timeout (Seconds):5 Use Root:On Store Output In:%output Store Errors In:%error Store Result In: Continue Task After Error:On ]
A8: Popup [ Title: Text:am wirft einen Fehler:
%error Background Image: Layout:PopupFullVerySmallFont Timeout (Seconds):60 Show Over Keyguard:Off ] If [ %error Set ]
A9: Destroy Scene [ Name:TaskKill ]
A10: Else
A11: Destroy Scene [ Name:TaskKill ]
A12: End If


This is the scene:

Scene: TaskKill
P:1080x1920 L:-1x-1

Orientation: System
Background Colour: #FF000000
Action Bar Style: System
Title: TaskKill
Subtitle:
Icon: null
Tab Labels:

Element: Menu1/Menu
Geometry:
P:0,0 1080x1920 L:0,390 1080x494
Content:
Source: Variable Array
Variable: %output
Selection Mode: None
Item Layout: Builtin Item Layout
Horizontal Space: 0
Vertical Space: 0
Events:
ItemClick: 264
ItemLongClick: 267


The next thing would be a search in the top of the menu where I could filter the processes. But think that I won't do this work.
Thanks
Frank

Rich D

unread,
Oct 17, 2015, 5:37:30 PM10/17/15
to Tasker Google Groups Post


On Oct 17, 2015 5:09 PM, "francwalter"

> The next thing would be a search in the top of the menu where I could filter the processes. But think that I won't do this work.

What type of sort. I have some existing tasks that will sort the menu as you type in text. IE start typing 'd' you get all items starting with d then type 'o' get all items starting with 'do' then type 'g' then the search will switch to all items containing the word 'dog' any where in the text.    Let me know if you are interested.

Frank Röhm

unread,
Oct 17, 2015, 6:10:56 PM10/17/15
to tas...@googlegroups.com
Yes exactly this I want! I am interested :)
Could you post it?

I found now also the "Test App" Action (under Apps) where I can use the package name to show the human readable App Name (e.g. com.whatsapp > WhatsApp).
I use this now for long press on the package-name, this shows then the App Name.
But better it would be to show only the App Name in the Menu. Then It is easier to recognize the process. E.g. net.dinglisch.android.tasker = Tasker (better to read).
This is but a problem because the Menu entry cannot contain two variables, only one, the label.
I use the Label name (package-name) to kill the process, for this I need the package name not the app name. As there is with the Test App action no way to go from App Name back to the package-name I am stuck here and I stay with the package-name in the menu’s kill list.
But with your progressive search this would be enough anyway :)

Thank advancely


Rich D

unread,
Oct 17, 2015, 6:18:39 PM10/17/15
to Tasker Google Groups Post

> I use the Label name (package-name) to kill the process, for this I need the package name not the app name. As there is with the Test App action no way to go from App Name back to the package-name I am stuck here

A few ways to do that. You can create duplicate arrays so the package name in one array has the same array index number as the app name in the other. Then instead of using %tap_label   use %tap_index

I will pull out my sort task and post it when I get some time...  

Rich D

unread,
Oct 18, 2015, 9:12:31 AM10/18/15
to Tasker Google Groups Post


> Yes exactly this I want! I am interested :)
> Could you post it?

Ok, here is a test project with a basic menu and the sort task.  Import the project and run the 'Test task' task with the play button. Type your search into the text edit box.  The menu uses a comma separated variable to fill populate the menu.

Feel free to post back with any questions. 

Array_Sort_2.prj.xml

Rich D

unread,
Oct 18, 2015, 10:07:49 AM10/18/15
to Tasker Google Groups Post


> Ok, here is a test project

The best way to get info on any actions or variables you are not familiar with is to use the menu / search tasker feature.  

If you do use this in your project you will need to change the ' duplicate array'  approach I mentioned earlier.  You would still make the same duplicate arrays only go back to using %tap_label then use the array search feature
//
%arr(#?b/c)
A comma-separated list of the array indices (lowest to highest) with matching values, or 0 if none match (2,3 in the example)
//
To find the correct index number for the array with just the names then use that as the index number in the array containing the package names.

Frank Röhm

unread,
Oct 19, 2015, 6:37:28 AM10/19/15
to tas...@googlegroups.com

> Am 18.10.2015 um 16:07 schrieb Rich D <ricp...@gmail.com>:
>
> > Ok, here is a test project
>

Thank!

> The best way to get info on any actions or variables you are not familiar with is to use the menu / search tasker feature.
>

Yes good hint! I discovered this helpful help tool only weeks ago, but use it too seldom.

> If you do use this in your project you will need to change the ' duplicate array' approach I mentioned earlier. You would still make the same duplicate arrays only go back to using %tap_label then use the array search feature
> //
> %arr(#?b/c)
> A comma-separated list of the array indices (lowest to highest) with matching values, or 0 if none match (2,3 in the example)
> //
> To find the correct index number for the array with just the names then use that as the index number in the array containing the package names.
>

The sorting works flawless, very nice Task, thank!
Now I go for the replace the package name to humans name and do this as you mentioned.
Will take a bit…

Rich D

unread,
Oct 19, 2015, 6:57:33 AM10/19/15
to Tasker Google Groups Post

> Now I go for the replace the package name to humans name and do this as you mentioned.
> Will take a bit…

Just to clarify that a bit. you should end up with the  2 similar arrays and then set a comma separated  "variable" (not variable array) for the menu Items.  I would have to go back and re-test but for some reason I think when you use a 'variable array' for the menu items the menu does not update when the array is modified. However it will update when using a comma separated "variable" just use a
action / variable set : %newvar. TO: %var_array(:)
This will give you the comma separated variable.

Then after the item is selected you will just need the test the %tap_label against the array (using the array search I mentioned)  Containing the names to get the correct index number to use in the package array.

Simple aye... ?     :)

francwalter

unread,
Oct 19, 2015, 5:48:28 PM10/19/15
to Tasker
Am Montag, 19. Oktober 2015 12:57:33 UTC+2 schrieb Rich D:

> Now I go for the replace the package name to humans name and do this as you mentioned.
> Will take a bit…

Just to clarify that a bit. you should end up with the  2 similar arrays and then set a comma separated  "variable" (not variable array) for the menu Items.  I would have to go back and re-test but for some reason I think when you use a 'variable array' for the menu items the menu does not update when the array is modified.


Exact!
 

However it will update when using a comma separated "variable" just use a
action / variable set : %newvar. TO: %var_array(:)
This will give you the comma separated variable.

Then after the item is selected you will just need the test the %tap_label against the array (using the array search I mentioned)  Containing the names to get the correct index number to use in the package array.


This is the crucial part. I did this, and the task generates a list with the human names, but I discovered the main drawback in this thing: it takes much too long to find all human names of all packages. 10 Seconds for all apps. That is unbearable.
So I end up with the fast package list which is magnificantly sortable with your alkorythm, this works well-well.
As the most apps contain their human name more or less in their package name, it is not that problem.

Now I have a fast and working task killer and after all, I learned about arrays as well.

Thank you very much.
frank

in the next post I will post the description of the tasks and scenes.

francwalter

unread,
Oct 19, 2015, 6:03:16 PM10/19/15
to Tasker
The Task "TaskKill":

Taskkill (169)
   
Abort Existing Task
    A1
: Run Shell [ Command:ps | grep u0_ | awk '{print $9 ","}' Timeout (Seconds):0 Use Root:On Store Output In:%Menu_data_start Store Errors In: Store Result In: ]
    A2
: Variable Search Replace [ Variable:%Menu_data_start Search:\s Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
    A3
: Variable Set [ Name:%Menu_data To:%Menu_data_start Do Maths:Off Append:Off ]
    A4
: Show Scene [ Name:TaskKill Display As:Activity, Full Window, No Bar Horizontal Position:100 Vertical Position:100 Animation:System Show Exit Button:Off Continue Task Immediately:Off ]
    A5
: Flash [ Text:TaskKill beendet. Long:Off ]
    A6
: Destroy Scene [ Name:TaskKill ]

The Sort Task (from Rich):

SortList (277)
   
Abort Existing Task
    A1
: Variable Clear [ Name:%fileslista Pattern Matching:Off ]
    A2
: Variable Set [ Name:%search To:%par1 Do Maths:Off Append:Off ]
    A3
: Variable Convert [ Name:%search Function:To Lower Case Store Result In: ]
    A4
: Variable Set [ Name:%search To:+ Do Maths:Off Append:Off ] If [ %search ~ . | %search ~ \%new_val ]
   
<skip stop>
    A5
: Test Variable [ Type:Length Data:%search Store Result In:%varlength ]
    A6
: Variable Set [ Name:%field_data To:%Menu_data_start Do Maths:Off Append:Off ]
   
<start loop>
    A7
: Anchor
    A8
: Variable Split [ Name:%field_data Splitter:, Delete Base:Off ]
    A9
: Variable Set [ Name:%matches To:%field_data(#?%search*) Do Maths:Off Append:Off ] If [ %varlength < 3 ]
    A10
: Variable Set [ Name:%matches To:%field_data(#?*%search*) Do Maths:Off Append:Off ] If [ %varlength > 2 ]
    A11
: If [ %matches ~ 0 ]
    A12
: Variable Set [ Name:%fileslista To:No Matches Do Maths:Off Append:Off ]
    A13
: Goto [ Type:Action Label Number:1 Label:skip loop ]
    A14
: End If
    A15
: Variable Split [ Name:%matches Splitter:, Delete Base:Off ]
    A16
: For [ Variable:%item Items:%matches(:) ]
    A17
: Variable Set [ Name:%fileslista To:%field_data(%item), Do Maths:Off Append:On ]
    A18
: End For
    A19
: Stop [ With Error:Off Task: ] If [ %fileslista ~ *fileslista* ]
   
<skip loop>
    A20
: Variable Set [ Name:%Menu_data To:%fileslista Do Maths:Off Append:Off ]
    A21
: Variable Clear [ Name:%fileslista Pattern Matching:Off ]
    A22
: Array Clear [ Name:%fileslista ]

and the scene where it is used and where the apps are killed:

Scene: TaskKill
    P
:1080x1920    L:-1x-1

       
Orientation: System
       
Background Colour: #FF000000
       
Action Bar Style: System
       
Title: TaskKill
       
Subtitle:
       
Icon: null
       
Tab Labels:

Element: Menu_Tasks/Menu
   
Geometry:
        P
:0,185 1080x1735 L:0,390 1080x494
   
Content:
       
Source: Variable
       
Variable: %Menu_data
       
Selection Mode: Single

       
Item Layout: Builtin Item Layout

       
Horizontal Space: 1
       
Vertical Space: 1
   
Events:
       
ItemClick: 285
       
ItemLongClick: 286
   
Items:
       
1. Label: de.thecode.android.tazreader

Element: Btn_Help/Button
   
Geometry:
        P
:2,1710 149x150 L:2,1770 149x150
   
Content:
       
Label:
       
Label Size: 16
       
Label Width Scale %: 100
       
Label Colour: #FF000000
       
Font:
       
Position: Centre
       
Icon: hd_action_help
   
Events:
       
Click: 287

Element: Btn_Close/Button
   
Geometry:
        P
:927,1710 149x150 L:931,1770 149x150
   
Content:
       
Label:
       
Label Size: 16
       
Label Width Scale %: 100
       
Label Colour: #FF000000
       
Font:
       
Position: Centre
       
Icon: hd_ab_content_remove
   
Events:
       
Click: 288

Element: Btn_Keep/Button
   
Geometry:
        P
:930,0 150x150 L:930,0 150x150
   
Content:
       
Label:
       
Label Size: 16
       
Label Width Scale %: 100
       
Label Colour: #FF000000
       
Font:
       
Position: Centre
       
Icon: hd_ab_navigation_collapse
   
Events:
       
Click: 289

Element: Txt_search/TextEdit
   
Geometry:
        P
:1,0 1079x185 L:1,0 1079x185
   
Content:
       
Text:
       
Text Size: 22
       
Text Width Scale Percent: 100
       
Text Colour: #FFFFFFFF
       
Font:
       
Position: Centre
       
Input Type: Normal Text
       
Maximum Characters: 1000
   
Events:
       
ValueSelected: 290



Frank Röhm

unread,
Oct 19, 2015, 6:09:20 PM10/19/15
to tas...@googlegroups.com
Attached the project as export
Task.prj.xml

Rich D

unread,
Oct 19, 2015, 6:13:22 PM10/19/15
to Tasker Google Groups Post


> This is the crucial part. I did this, and the task generates a list with the human names, but I discovered the main drawback in this thing: it takes much too long to find all human names of all packages. 10 Seconds for all apps. That is unbearable.

This is most likely because you used a global variable  array in your sort loop. You should be using almost all
Local variables and arrays whenever possible. If you convert it to a local array before the process loop it will run much faster. 

> Now I have a fast and working task killer and after all, I learned about arrays as well.

Great..

>
> Thank you very much.

Your welcome..

francwalter

unread,
Oct 19, 2015, 6:21:47 PM10/19/15
to Tasker
Am Dienstag, 20. Oktober 2015 00:13:22 UTC+2 schrieb Rich D:


> This is the crucial part. I did this, and the task generates a list with the human names, but I discovered the main drawback in this thing: it takes much too long to find all human names of all packages. 10 Seconds for all apps. That is unbearable.

This is most likely because you used a global variable  array in your sort loop. You should be using almost all
Local variables and arrays whenever possible. If you convert it to a local array before the process loop it will run much faster. 



Unfortunately not. This was my test:

TestTaskKill (278)
   
Abort Existing Task
    A1
: Run Shell [ Command:ps | grep u0_ | awk '{print $9 ","}' Timeout (Seconds):0 Use Root:On Store Output In:%output Store Errors In: Store Result In: ]

    A2
: Variable Search Replace [ Variable:%output Search:\s Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]

    A3
: Variable Split [ Name:%output Splitter:, Delete Base:Off ]
    A4
: For [ Variable:%package Items:%output() ]
    A5
: Test App [ Type:Package Name Data:%package Store Result In:%appname Continue Task After Error:On ]
    A6
: Array Push [ Name:%Menu_data_apps Position:1 Value:%appname Fill Spaces:Off ]
    A7
: End For

and this took 10 secs.
I didn’t test it with Global variables though, I guess then it is surely even slower.


Juergen Gruen

unread,
Oct 19, 2015, 6:25:32 PM10/19/15
to Tasker
%Menu_data_apps is a global variable...

Frank Röhm

unread,
Oct 19, 2015, 6:48:22 PM10/19/15
to tas...@googlegroups.com

> Am 20.10.2015 um 00:25 schrieb Juergen Gruen <androi...@googlemail.com>:
>
> %Menu_data_apps is a global variable…

for only the results. I thought that would not be the difference, but indeed, it is, a bit at least.
Instead of 10 seconds it takes 8 seconds.

Rich D

unread,
Oct 19, 2015, 9:25:50 PM10/19/15
to Tasker Google Groups Post


> > %Menu_data_apps is a global variable…
>
> for only the results. I thought that would not be the difference, but indeed, it is, a bit at least.
> Instead of 10 seconds it takes 8 seconds.

Huh... must be one of the processes. However now that you are an array expert, you should be able to build your own package name converter.  You can make an array that contains the package name and app name which would be populated only when there was a unknown package name. So the first time you ran the app it would take the 8 seconds then it should get faster with each use until you get all the possible package names. So one of the elements would look like this.

%App_names(1) = package name|app name

So you would first test this array to see if it is a known package name, if it is just split %App_names(1) to get the app name,  if it is not known then test the app and add the info to the array. 

Just a thought.....  :)

Frank Röhm

unread,
Oct 20, 2015, 11:00:27 AM10/20/15
to tas...@googlegroups.com
Am 20. Oktober 2015 03:25:33 MESZ, schrieb Rich D <ricp...@gmail.com>:
>> >can make an array that contains the package name and app name which
>would
>be populated only when there was a unknown package name.

Great! Yes, this a good idea! !
Thanks :)

Ok, I got it in only 6 seconds now :)
Attached the project.

Next would be, to re scan the list if I killed a process, because this process should disappear. But often the process restarts, so it is not done with delete only from my arrays.
This would then but take again so long.
I get most processes now from my array but this also takes time.
See, here is description:

TaskKillNames (278)
Abort Existing Task
A1: Variable Clear [ Name:%Menu_data Pattern Matching:Off ]
A2: Variable Clear [ Name:%Menu_data_start Pattern Matching:Off ]
A3: Run Shell [ Command:ps | grep u0_ | awk '{print $9 ","}' Timeout (Seconds):0 Use Root:On Store Output In:%output Store Errors In: Store Result In: ]
A4: Variable Search Replace [ Variable:%output Search:\s Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A5: Variable Search Replace [ Variable:%output Search:,su, Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With:, ]
A6: Variable Search Replace [ Variable:%output Search:,su, Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With:, ]
A7: Variable Search Replace [ Variable:%output Search:,[^,]*/[^,]*, Ignore Case:On Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With:, ]
A8: Variable Search Replace [ Variable:%output Search:,[^,]*:[^,]*, Ignore Case:On Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With:, ]
A9: Variable Search Replace [ Variable:%output Search:,([^,]*):[^,]*, Ignore Case:On Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With:,$1, ]
A10: Variable Split [ Name:%output Splitter:, Delete Base:Off ]
A11: Array Process [ Variable:%output Type:Remove Duplicates ]
A12: Array Process [ Variable:%output Type:Sort Alpha ]
A13: Array Process [ Variable:%output Type:Squash ]
A14: Variable Set [ Name:%Count_proc To:%output(#) Do Maths:Off Append:Off ]
A15: For [ Variable:%package Items:%output() ]
A16: Variable Clear [ Name:%appname Pattern Matching:Off ]
A17: If [ %Apps_package(#?%package) eq 0 ]
A18: Test App [ Type:Package Name Data:%package Store Result In:%appname Continue Task After Error:On ]
A19: If [ %appname Set ]
A20: If [ %Apps_name(#?%appname) eq 0 ]
A21: Array Push [ Name:%Apps_package Position:1 Value:%package Fill Spaces:Off ]
A22: Array Push [ Name:%Apps_name Position:1 Value:%appname Fill Spaces:Off ]
A23: End If
A24: End If
A25: End If
A26: End For
A27: Variable Clear [ Name:%Menu_data Pattern Matching:Off ]
A28: Variable Clear [ Name:%Menu_data_start Pattern Matching:Off ]
A29: Variable Set [ Name:%Menu_data_start To:%Apps_name() Do Maths:Off Append:Off ]
A30: Variable Set [ Name:%Menu_data To:%Apps_name() Do Maths:Off Append:Off ]
A31: Show Scene [ Name:TaskKillNames Display As:Activity, Full Window, No Bar Horizontal Position:100 Vertical Position:100 Animation:System Show Exit Button:Off Continue Task Immediately:Off ]
A32: Destroy Scene [ Name:TaskKillNames ]
A33: Flash [ Text:TaskKill beendet. Long:Off ]
A34: Variable Clear [ Name:%Menu_data Pattern Matching:Off ]
A35: Variable Clear [ Name:%Menu_data_start Pattern Matching:Off ]




SortListNames (275)

Abort Existing Task
A1: Variable Clear [ Name:%fileslista Pattern Matching:Off ]
A2: Variable Set [ Name:%search To:%par1 Do Maths:Off Append:Off ]
A3: Variable Convert [ Name:%search Function:To Lower Case Store Result In: ]
A4: Variable Set [ Name:%search To:+ Do Maths:Off Append:Off ] If [ %search ~ . | %search ~ \%new_val ]
<skip stop>
A5: Test Variable [ Type:Length Data:%search Store Result In:%varlength ]
A6: Variable Set [ Name:%field_data To:%Menu_data_start Do Maths:Off Append:Off ]
<start loop>
A7: Anchor
A8: Variable Split [ Name:%field_data Splitter:, Delete Base:Off ]
A9: Variable Set [ Name:%matches To:%field_data(#?%search*) Do Maths:Off Append:Off ] If [ %varlength < 3 ]
A10: Variable Set [ Name:%matches To:%field_data(#?*%search*) Do Maths:Off Append:Off ] If [ %varlength > 2 ]
A11: If [ %matches ~ 0 ]
A12: Variable Set [ Name:%fileslista To:No Matches Do Maths:Off Append:Off ]
A13: Goto [ Type:Action Label Number:1 Label:skip loop ]
A14: End If
A15: Variable Split [ Name:%matches Splitter:, Delete Base:Off ]
A16: For [ Variable:%item Items:%matches(:) ]
A17: Variable Set [ Name:%fileslista To:%field_data(%item), Do Maths:Off Append:On ]
A18: End For
A19: Stop [ With Error:Off Task: ] If [ %fileslista ~ *fileslista* ]
<skip loop>
A20: Variable Set [ Name:%Menu_data To:%fileslista Do Maths:Off Append:Off ]
A21: Variable Clear [ Name:%fileslista Pattern Matching:Off ]
A22: Array Clear [ Name:%fileslista ]





Scene: TaskKillNames

P:1080x1920 L:-1x-1

Orientation: System
Background Colour: #FF000000
Action Bar Style: System
Title: TaskKill
Subtitle:
Icon: null
Tab Labels:

Element: Menu_Tasks/Menu
Geometry:
P:0,185 1080x1735 L:0,390 1080x494
Content:
Source: Variable

Variable: %Menu_data
Selection Mode: Single
Item Layout: Builtin Item Layout
Horizontal Space: 1
Vertical Space: 1
Events:
ItemClick: 279
ItemLongClick: 280


Element: Btn_Help/Button
Geometry:
P:2,1710 149x150 L:2,1770 149x150
Content:
Label:
Label Size: 16
Label Width Scale %: 100
Label Colour: #FF000000
Font:
Position: Centre
Icon: hd_action_help
Events:
Click: 281


Element: Btn_Close/Button
Geometry:
P:927,1710 149x150 L:931,1770 149x150
Content:
Label:
Label Size: 16
Label Width Scale %: 100
Label Colour: #FF000000
Font:
Position: Centre
Icon: hd_ab_content_remove
Events:
Click: 282
LongClick: 297

Element: Btn_Keep/Button
Geometry:
P:927,0 150x185 L:930,0 150x150

Content:
Label:
Label Size: 16
Label Width Scale %: 100
Label Colour: #FF000000
Font:
Position: Centre
Icon: hd_ab_navigation_collapse
Events:
Click: 283
LongClick: 301

Element: Txt_search/TextEdit
Geometry:
P:152,0 774x185 L:1,0 1079x185

Content:
Text:
Text Size: 22
Text Width Scale Percent: 100
Text Colour: #FFFFFFFF
Font:
Position: Centre
Input Type: Normal Text
Maximum Characters: 1000
Events:
ValueSelected: 284

Element: Txt_countapps/Text
Geometry:
P:0,10 151x175 L:0,185 175x125
Content:
Text: %Count_proc

Text Size: 22
Text Width Scale Percent: 100
Text Colour: #FFFF0000
Font:
Position: Centre
Vertical Fit Mode: None
Text Format: Plain Text
Events:
Click: 299
LongClick: 300

Element: Btn_ClearArray/Button
Geometry:
P:902,1460 175x175 L:902,1460 175x175
Content:
Label: Clear Arrays

Label Size: 16
Label Width Scale %: 100
Label Colour: #FFFF0000
Font:
Position: Centre
Icon: null
Events:
Click: 295
LongClick: 296
Taskkill.prj.xml

Rich D

unread,
Oct 20, 2015, 5:29:16 PM10/20/15
to Tasker Google Groups Post


> Great! Yes, this a good idea! !
> Thanks :)
>
> Ok, I got it in only 6 seconds now :)
> Attached the project.

Not sure if this is what I was thinking..

Here is how i thought it might go. You would create another variable  called %All_names and give it a value of a comma   ","

Abort Existing Task

-Variable set %all_names TO: %All_names
-Variable split %all_names

    A1: Run Shell [ Command:ps | grep u0_ | awk '{print $9 ","}' Timeout (Seconds):0 Use Root:On Store Output In:%output Store Errors In: Store Result In: ]

    A2: Variable Search Replace [ Variable:%output Search:\s Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]

    A3: Variable Split [ Name:%output Splitter:, Delete Base:Off ]
    A4: For [ Variable:%package Items:%output() ]

-Variable set %index TO: %all_names(#?*%package*)
-If %index ~ 0
        - Test App [ Type:Package Name Data:%package Store Result In:%appname Continue Task After Error:On ]
       - Array Push [ Name:%all_names Position:1 Value:%package|%appname Fill Spaces:Off ]
         -Variable set %index TO: 1
-End if
 -Variable set %temp TO: %all_names(%index)
-Variable split %temp Splitter: |
-Array Push [ Name:%Menu_data_apps Position:1 Value:%temp(2) Fill Spaces:Off ]
End If

 A7: End For
-variable set %All_names TO: %all_names

Every time the task is tun this should populate the array %all_names with the package name|app name of every package name it does not already have.  So it will eventually learn all the package and app names and will not have to use the 'test app' action which is slowing everthing down.  It saves the local array to a global comma seperated variable at the end of the task and repopulates it at the begining of the task 

Frank Röhm

unread,
Oct 20, 2015, 5:51:48 PM10/20/15
to tas...@googlegroups.com

> Am 20.10.2015 um 23:28 schrieb Rich D <ricp...@gmail.com>:
>
> ...
> -Variable set %index TO: %all_names(#?*%package*)
> -If %index ~ 0
> - Test App [ Type:Package Name Data:%package Store Result In:%appname Continue Task After Error:On ]
> - Array Push [ Name:%all_names Position:1 Value:%package|%appname Fill Spaces:Off ]
>

This is the big difference I found: you use one array with both values in each array-value: package|appname (separated with a | )
I use two arrays with same indexes, so they are corresponding together.
I looked into my code, when I disable the gathering of new app names (through the test app action) the time is the same.
In my code the time consuming is not the Test App but mostly the For Next (now).

Do you think that with the gathering into one array the time could be slowed to 3 seconds?
If yes, then I will re-write this.


Rich D

unread,
Oct 20, 2015, 8:40:29 PM10/20/15
to Tasker Google Groups Post

> > -Variable set %index TO: %all_names(#?*%package*)
> > -If %index ~ 0
> >         - Test App [ Type:Package Name Data:%package Store Result In:%appname Continue Task After Error:On ]
> >        - Array Push [ Name:%all_names Position:1 Value:%package|%appname Fill Spaces:Off ]
> >
>
> This is the big difference I found: you use one array with both values in each array-value: package|appname (separated with a | )
> I use two arrays with same indexes, so they are corresponding together.

Ok, got it now..

> I looked into my code, when I disable the gathering of new app names (through the test app action) the time is the same.
> In my code the time consuming is not the Test App but mostly the For Next (now).

How are you confirming this?  The run log would confirm it an show if there were any errors and if all is running as expected. Menu / more / run log

>
> Do you think that with the gathering into one array the time could be slowed to 3 seconds?

Not sure, but it would be less complex and have less actions.

You are still using several global variables in the for loop. I changed my suggestion to exclude all global variables within the for loop.  This should make a difference.



> Abort Existing Task
>
> -Variable set %all_names TO: %All_names
> -Variable split %all_names
>
>     A1: Run Shell [ Command:ps | grep u0_ | awk '{print $9 ","}' Timeout (Seconds):0 Use Root:On Store Output In:%output Store Errors In: Store Result In: ]
>
>     A2: Variable Search Replace [ Variable:%output Search:\s Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
>
>     A3: Variable Split [ Name:%output Splitter:, Delete Base:Off ]
>     A4: For [ Variable:%package Items:%output() ]
>

> -Variable set %index TO: %all_names(#?*%package*)
> -If %index ~ 0
>         - Test App [ Type:Package Name Data:%package Store Result In:%appname Continue Task After Error:On ]
>        - Array Push [ Name:%all_names Position:1 Value:%package|%appname Fill Spaces:Off ]

>          -Variable set %index TO: 1
> -End if
>  -Variable set %temp TO: %all_names(%index)
> -Variable split %temp Splitter: |

> -variable set  %menu_data_apps to %temp(2), append on.


> End If
>
>  A7: End For

> -variable set %All_names TO: %all_names(:)
   -Variable set %Menu_data_app TO: %menu_data_apps

Instead of pushing to array %Menu_data_apps I appened %temp(2), (note the comma) to a local variable . This makes it a comma separated variable that the menu can use directly.

Now there are no global variables in the for loop.

To get the package name after a menu tap do

-Variable set %all_names TO: %All_names

- variable split %all_names
-Variable set %index TO: %all_names(#?*%tap_label*)
- variable set %temp To: %all_names(%index)
- Variable split %temp  splitter |
Your package name is now in %temp1

May need some tweeking, but that is the general idea. I believe removing all global variables from the for loop will make a difference.  This also removes the need for any parallel arrays.

Rich D

unread,
Oct 20, 2015, 8:53:15 PM10/20/15
to Tasker Google Groups Post


I have found it is always better to have a global comma separated variable and split it to a local array any time you need to use it then having a global variable array.  The action to set a local variable to a global comma separated variable is far less taxing on tasker then preforming any action on a global array.

Frank Röhm

unread,
Oct 21, 2015, 5:28:39 AM10/21/15
to tas...@googlegroups.com

> Am 21.10.2015 um 02:52 schrieb Rich D <ricp...@gmail.com>:
>
>
> I have found it is always better to have a global comma separated variable and split it to a local array any time you need to use it then having a global variable array. The action to set a local variable to a global comma separated variable is far less taxing on tasker then preforming any action on a global array.

This you very right! What me self bother the most ist the many many variables in the Variables Tab of Tasker. With my (at the moment still) App_package and App_name arrays I have about 80 vars in this tab, this makes it less usable I think.

francwalter

unread,
Oct 21, 2015, 7:15:37 AM10/21/15
to Tasker
Am Mittwoch, 21. Oktober 2015 02:40:29 UTC+2 schrieb Rich D:

> > ...

> I looked into my code, when I disable the gathering of new app names (through the test app action) the time is the same.
> In my code the time consuming is not the Test App but mostly the For Next (now).

How are you confirming this?  The run log would confirm it an show if there were any errors and if all is running as expected. Menu / more / run log

>


This is my running log:

20151021 12.46.34 E Start    ID0:0.0  TaskService
20151021 12.50.07 E Stop     ID0:0.0  TaskService
20151021 12.50.10 E Start    ID0:0.0  TaskService
20151021 12.50.11 T Running  ID278    TaskKillNames
20151021 12.50.12 A OK       ID278.1  TaskKillNames.Var Clear, %Menu_data=%Menu_data
20151021 12.50.12 A OK       ID278.2  TaskKillNames.Var Clear, %Menu_data_start=%Menu_data_start
20151021 12.50.12 A OK       ID278.3  TaskKillNames.Run Shell, %output=%output
20151021 12.50.12 A OK       ID278.4  TaskKillNames.Var Search Replace, %output=com.android.system..
20151021 12.50.12 A OK       ID278.5  TaskKillNames.Var Search Replace, %output=com.android.system..
20151021 12.50.12 A OK       ID278.6  TaskKillNames.Var Search Replace, %output=com.android.system..
20151021 12.50.12 A OK       ID278.7  TaskKillNames.Var Search Replace, %output=com.android.system..
20151021 12.50.12 A OK       ID278.8  TaskKillNames.Var Search Replace, %output=com.android.system..
20151021 12.50.12 A OK       ID278.9  TaskKillNames.Var Search Replace, %output=com.android.system..
20151021 12.50.12 A OK       ID278.10 TaskKillNames.Var Split, %output=com.android.system..
20151021 12.50.12 A OK       ID278.11 TaskKillNames.Array Process, %output=com.android.system..
20151021 12.50.12 A OK       ID278.12 TaskKillNames.Array Process, %output=com.android.system..
20151021 12.50.12 A OK       ID278.13 TaskKillNames.Array Process, %output=com.android.system..
20151021 12.50.12 A OK       ID278.14 TaskKillNames.Var Set, %Count_proc=36
20151021 12.50.12 A OK       ID278.15 TaskKillNames.For, %package=android.process.ac..
20151021 12.50.13 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.13 A OK       ID278.17 TaskKillNames.If
20151021 12.50.13 A ErrIgnore ID278.18 TaskKillNames.Test App, %appname=%appname
20151021 12.50.13 A OK       ID278.19 TaskKillNames.If
20151021 12.50.13 A OK       ID278.25 TaskKillNames.End If
20151021 12.50.13 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.13 A OK       ID278.15 TaskKillNames.For, %package=android.process.me..
20151021 12.50.13 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.13 A OK       ID278.17 TaskKillNames.If
20151021 12.50.13 A ErrIgnore ID278.18 TaskKillNames.Test App, %appname=%appname
20151021 12.50.13 A OK       ID278.19 TaskKillNames.If
20151021 12.50.13 A OK       ID278.25 TaskKillNames.End If
20151021 12.50.13 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.13 A OK       ID278.15 TaskKillNames.For, %package=com.amazing_create..
20151021 12.50.13 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.13 A OK       ID278.17 TaskKillNames.If
20151021 12.50.13 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.13 A OK       ID278.15 TaskKillNames.For, %package=com.anddoes.launcher
20151021 12.50.13 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.13 A OK       ID278.17 TaskKillNames.If
20151021 12.50.13 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.13 A OK       ID278.15 TaskKillNames.For, %package=com.android.galler..
20151021 12.50.13 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.13 A OK       ID278.17 TaskKillNames.If
20151021 12.50.13 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.13 A OK       ID278.15 TaskKillNames.For, %package=com.android.incallui
20151021 12.50.13 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.13 A OK       ID278.17 TaskKillNames.If
20151021 12.50.13 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.13 A OK       ID278.15 TaskKillNames.For, %package=com.android.inputm..
20151021 12.50.13 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.13 A OK       ID278.17 TaskKillNames.If
20151021 12.50.13 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.13 A OK       ID278.15 TaskKillNames.For, %package=com.android.provid..
20151021 12.50.13 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.13 A OK       ID278.17 TaskKillNames.If
20151021 12.50.13 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.13 A OK       ID278.15 TaskKillNames.For, %package=com.android.smspush
20151021 12.50.13 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.13 A OK       ID278.17 TaskKillNames.If
20151021 12.50.13 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.13 A OK       ID278.15 TaskKillNames.For, %package=com.android.systemui
20151021 12.50.13 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.13 A OK       ID278.17 TaskKillNames.If
20151021 12.50.14 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.14 A OK       ID278.15 TaskKillNames.For, %package=com.android.vending
20151021 12.50.14 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.14 A OK       ID278.17 TaskKillNames.If
20151021 12.50.14 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.14 A OK       ID278.15 TaskKillNames.For, %package=com.appgenix.bizcal
20151021 12.50.14 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.14 A OK       ID278.17 TaskKillNames.If
20151021 12.50.14 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.14 A OK       ID278.15 TaskKillNames.For, %package=com.cyanogenmod.tr..
20151021 12.50.14 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.14 A OK       ID278.17 TaskKillNames.If
20151021 12.50.14 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.14 A OK       ID278.15 TaskKillNames.For, %package=com.fjsoft.myphone..
20151021 12.50.14 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.14 A OK       ID278.17 TaskKillNames.If
20151021 12.50.14 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.14 A OK       ID278.15 TaskKillNames.For, %package=com.fsck.k9
20151021 12.50.14 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.14 A OK       ID278.17 TaskKillNames.If
20151021 12.50.14 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.14 A OK       ID278.15 TaskKillNames.For, %package=com.google.android..
20151021 12.50.14 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.14 A OK       ID278.17 TaskKillNames.If
20151021 12.50.14 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.14 A OK       ID278.15 TaskKillNames.For, %package=com.google.android..
20151021 12.50.14 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.14 A OK       ID278.17 TaskKillNames.If
20151021 12.50.14 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.14 A OK       ID278.15 TaskKillNames.For, %package=com.google.android..
20151021 12.50.14 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.14 A OK       ID278.17 TaskKillNames.If
20151021 12.50.14 A ErrIgnore ID278.18 TaskKillNames.Test App, %appname=%appname
20151021 12.50.14 A OK       ID278.19 TaskKillNames.If
20151021 12.50.14 A OK       ID278.25 TaskKillNames.End If
20151021 12.50.14 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.14 A OK       ID278.15 TaskKillNames.For, %package=com.google.android..
20151021 12.50.14 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.14 A OK       ID278.17 TaskKillNames.If
20151021 12.50.14 A ErrIgnore ID278.18 TaskKillNames.Test App, %appname=%appname
20151021 12.50.14 A OK       ID278.19 TaskKillNames.If
20151021 12.50.14 A OK       ID278.25 TaskKillNames.End If
20151021 12.50.14 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.14 A OK       ID278.15 TaskKillNames.For, %package=com.google.process..
20151021 12.50.14 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.14 A OK       ID278.17 TaskKillNames.If
20151021 12.50.15 A ErrIgnore ID278.18 TaskKillNames.Test App, %appname=%appname
20151021 12.50.15 A OK       ID278.19 TaskKillNames.If
20151021 12.50.15 A OK       ID278.25 TaskKillNames.End If
20151021 12.50.15 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.15 A OK       ID278.15 TaskKillNames.For, %package=com.joaomgcd.autoa..
20151021 12.50.15 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.15 A OK       ID278.17 TaskKillNames.If
20151021 12.50.15 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.15 A OK       ID278.15 TaskKillNames.For, %package=com.joaomgcd.autor..
20151021 12.50.15 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.15 A OK       ID278.17 TaskKillNames.If
20151021 12.50.15 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.15 A OK       ID278.15 TaskKillNames.For, %package=com.keramidas.Tita..
20151021 12.50.15 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.15 A OK       ID278.17 TaskKillNames.If
20151021 12.50.15 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.15 A OK       ID278.15 TaskKillNames.For, %package=com.nuance.swype.dtc
20151021 12.50.15 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.15 A OK       ID278.17 TaskKillNames.If
20151021 12.50.15 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.15 A OK       ID278.15 TaskKillNames.For, %package=com.schiztech.swapps
20151021 12.50.15 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.15 A OK       ID278.17 TaskKillNames.If
20151021 12.50.15 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.15 A OK       ID278.15 TaskKillNames.For, %package=com.skvalex.callre..
20151021 12.50.15 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.15 A OK       ID278.17 TaskKillNames.If
20151021 12.50.15 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.15 A OK       ID278.15 TaskKillNames.For, %package=com.whatsapp
20151021 12.50.15 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.15 A OK       ID278.17 TaskKillNames.If
20151021 12.50.15 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.15 A OK       ID278.15 TaskKillNames.For, %package=de.robv.android.xp..
20151021 12.50.15 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.15 A OK       ID278.17 TaskKillNames.If
20151021 12.50.15 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.16 A OK       ID278.15 TaskKillNames.For, %package=dev.ukanth.ufirewa..
20151021 12.50.16 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.16 A OK       ID278.17 TaskKillNames.If
20151021 12.50.16 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.16 A OK       ID278.15 TaskKillNames.For, %package=eu.chainfire.supersu
20151021 12.50.16 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.16 A OK       ID278.17 TaskKillNames.If
20151021 12.50.16 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.16 A OK       ID278.15 TaskKillNames.For, %package=mobi.conduction.sw..
20151021 12.50.16 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.16 A OK       ID278.17 TaskKillNames.If
20151021 12.50.16 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.16 A OK       ID278.15 TaskKillNames.For, %package=net.dinglisch.andr..
20151021 12.50.16 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.16 A OK       ID278.17 TaskKillNames.If
20151021 12.50.16 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.16 A OK       ID278.15 TaskKillNames.For, %package=org.cyanogenmod.au..
20151021 12.50.16 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.16 A OK       ID278.17 TaskKillNames.If
20151021 12.50.16 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.16 A OK       ID278.15 TaskKillNames.For, %package=org.cyanogenmod.pr..
20151021 12.50.16 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.16 A OK       ID278.17 TaskKillNames.If
20151021 12.50.16 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.16 A OK       ID278.15 TaskKillNames.For, %package=org.cyanogenmod.th..
20151021 12.50.16 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.17 A OK       ID278.17 TaskKillNames.If
20151021 12.50.17 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.17 A OK       ID278.15 TaskKillNames.For, %package=owncloud.pro
20151021 12.50.17 A OK       ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.17 A OK       ID278.17 TaskKillNames.If
20151021 12.50.17 A OK       ID278.26 TaskKillNames.End For
20151021 12.50.17 A OK       ID278.15 TaskKillNames.For, %package=%package
20151021 12.50.17 A OK       ID278.27 TaskKillNames.Var Clear, %Menu_data=%Menu_data
20151021 12.50.17 A OK       ID278.28 TaskKillNames.Var Clear, %Menu_data_start=%Menu_data_start
20151021 12.50.17 A OK       ID278.29 TaskKillNames.Var Set, %Menu_data_start=Google App,Google ..
20151021 12.50.17 A OK       ID278.30 TaskKillNames.Var Set, %Menu_data=Google App,Google ..
20151021 12.50.17 A OK       ID278.31 TaskKillNames.Show Scene
20151021 12.50.21 A OK       ID278.32 TaskKillNames.Destroy Scene
20151021 12.50.21 A OK       ID278.33 TaskKillNames.Flash
20151021 12.50.21 A OK       ID278.34 TaskKillNames.Var Clear, %Menu_data=%Menu_data
20151021 12.50.21 A OK       ID278.35 TaskKillNames.Var Clear, %Menu_data_start=%Menu_data_start
20151021 12.50.21 T ExitOK   ID278    TaskKillNames
20151021 12.50.22 E Stop     ID0:0.0  TaskService

 

francwalter

unread,
Oct 21, 2015, 7:53:39 PM10/21/15
to Tasker
Am Mittwoch, 21. Oktober 2015 02:53:15 UTC+2 schrieb Rich D:


I have found it is always better to have a global comma separated variable and split it to a local array any time you need to use it then having a global variable array.  The action to set a local variable to a global comma separated variable is far less taxing on tasker then preforming any action on a global array.


I discovered a logical bug in my task: i filled the menu with all known app-names, not only with the actual ones. So I had to change it and also now
I put now all global arrays out of the for next, where I have only lokal variables now.
But it takes now even longer, now 8 seconds.
I have the impression that the slow processing the if action is.

This now is my actual task:


TaskKillNames (278)
   
Abort Existing Task

    A1
: Flash [ Text:TaskKillNames wird gestartet, bitte warten... Long:Off ]
    A2
: Variable Set [ Name:%apps_package To:%Apps_package Do Maths:Off Append:Off ]
    A3
: Variable Split [ Name:%apps_package Splitter:, Delete Base:Off ]
    A4
: Variable Set [ Name:%apps_name To:%Apps_name Do Maths:Off Append:Off ]
    A5
: Variable Split [ Name:%apps_name Splitter:, Delete Base:Off ]
    A6
: Variable Clear [ Name:%Menu_data Pattern Matching:Off ]
    A7
: Variable Clear [ Name:%Menu_data_start Pattern Matching:Off ]
    A8
: Run Shell [ Command:ps | grep u0_ | awk '{print $9 ","}' Timeout (Seconds):0 Use Root:On Store Output In:%output Store Errors In: Store Result In: ]
    A9
: Variable Search Replace [ Variable:%output Search:\s Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
    A10
: Variable Search Replace [ Variable:%output Search:,su, Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With:, ]
    A11
: Variable Search Replace [ Variable:%output Search:,su, Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With:, ]
    A12
: Variable Search Replace [ Variable:%output Search:,[^,]*/[^,]*, Ignore Case:On Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With:, ]
    A13
: Variable Search Replace [ Variable:%output Search:,[^,]*:[^,]*, Ignore Case:On Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With:, ]
    A14
: Variable Search Replace [ Variable:%output Search:,([^,]*):[^,]*, Ignore Case:On Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With:,$1, ]
    A15
: Variable Split [ Name:%output Splitter:, Delete Base:Off ]
    A16
: Array Process [ Variable:%output Type:Remove Duplicates ]
    A17
: Array Process [ Variable:%output Type:Sort Alpha ]
    A18
: Array Process [ Variable:%output Type:Squash ]
    A19
: Variable Clear [ Name:%appname Pattern Matching:Off ]
    A20
: For [ Variable:%package Items:%output() ]
    A21
: Variable Set [ Name:%index To:%apps_package(#?%package) Do Maths:On Append:Off ]
    A22
: If [ %index = 0 ]
    A23
: Test App [ Type:Package Name Data:%package Store Result In:%appname Continue Task After Error:On ]
    A24
: If [ %appname Set ]
    A25
: If [ %apps_name(#?%appname) = 0 ]
    A26
: Array Push [ Name:%apps_package Position:1 Value:%package Fill Spaces:Off ]
    A27
: Array Push [ Name:%apps_name Position:1 Value:%appname Fill Spaces:Off ]
    A28
: Variable Set [ Name:%apps To:%appname, Do Maths:Off Append:On ]
    A29
: End If
    A30
: End If
    A31
: Else
    A32
: Variable Set [ Name:%apps To:%apps_name(%index), Do Maths:Off Append:On ]
    A33
: End If
    A34
: End For
    A35
: Variable Clear [ Name:%Menu_data Pattern Matching:Off ]
    A36
: Variable Clear [ Name:%Menu_data_start Pattern Matching:Off ]
    A37
: Variable Set [ Name:%Menu_data To:%apps Do Maths:Off Append:Off ]
    A38
: Variable Set [ Name:%Menu_data_start To:%apps Do Maths:Off Append:Off ]
    A39
: Variable Set [ Name:%Apps_package To:%apps_package() Do Maths:Off Append:Off ]
    A40
: Variable Set [ Name:%Apps_name To:%apps_name() Do Maths:Off Append:Off ]
    A41
: Variable Split [ Name:%apps Splitter:, Delete Base:Off ]
    A42
: Variable Set [ Name:%Count_proc To:%apps(#)/%output(#)/%apps_name(#) Do Maths:Off Append:Off ]
    A43
: Show Scene [ Name:TaskKillNames Display As:Activity, Full Window, No Bar Horizontal Position:100 Vertical Position:100 Animation:System Show Exit Button:Off Continue Task Immediately:Off ]
    A44
: Destroy Scene [ Name:TaskKillNames ]
    A45
: Flash [ Text:TaskKill beendet. Long:Off ]
    A46
: Variable Clear [ Name:%Menu_data Pattern Matching:Off ]
    A47
: Variable Clear [ Name:%Menu_data_start Pattern Matching:Off ]



Rich D

unread,
Oct 22, 2015, 5:29:04 AM10/22/15
to Tasker Google Groups Post

> I have the impression that the slow processing the if action is.

I have doing some testing and may be on to something. Here is my test task that takes 7 sec on my antique.

If I disable every thing in the for loop except action A13

A13: Variable Set [ Name:%index To:%all_names(#?*%package*) Do Maths:Off Append:Off ]

Then it still takes 7 seconds.

If I just put a IF statement in the loop like

IF. %all_names ~ *Package*

To do the test it runs in 2 seconds.  So if we use a simple match for the test we would need figure out the proper regex that will retrieve %package|%appname from the comma separated variable %all_names. This could ne done in action / variable search and replace / save matches in.

I am not a regex guy (hopefully you are) and it will take me some time to get this. But this could be the answer.

Get Names 2 (333)
A1: Vibrate [ Time:200 ]
A2: Variable Set [ Name:%all_names To:%All_names Do Maths:Off Append:Off ]
A3: Variable Split [ Name:%all_names Splitter:, Delete Base:Off ]
A4: Run Shell [ Command:ps | grep u0_ | awk '{print $9 ","}' Timeout (Seconds):0 Use Root:On Store Output In:%output Store Errors In: Store Result In: ]
A5: Variable Search Replace [ Variable:%output Search:,([^,]*):[^,]*, Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A6: Variable Search Replace [ Variable:%output Search:\s Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A7: Variable Search Replace [ Variable:%output Search:,su, Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A8: Variable Search Replace [ Variable:%output Search:,[^,]*/[^,]*, Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A9: Variable Search Replace [ Variable:%output Search:,[^,]*:[^,]*, Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A10: Variable Split [ Name:%output Splitter:, Delete Base:Off ]
A11: Array Process [ Variable:%output Type:Remove Duplicates ]
A12: For [ Variable:%package Items:%output(:) ]
A13: Variable Set [ Name:%index To:%all_names(#?*%package*) Do Maths:Off Append:Off ]
A14: If [ %index ~ 0 ]
A15: Test App [ Type:Package Name Data:%package Store Result In:%appname Continue Task After Error:On ]
A16: Array Push [ Name:%all_names Position:1 Value:%package|%appname Fill Spaces:On ]
A17: Variable Set [ Name:%index To:1 Do Maths:On Append:Off ]
A18: End If
A19: Variable Set [ Name:%temp To:%all_names(%index) Do Maths:Off Append:Off ]
A20: Variable Split [ Name:%temp Splitter:| Delete Base:Off ]
A21: Variable Set [ Name:%menu_data_apps To:%temp2, Do Maths:Off Append:On ]
A22: End For
A23: Vibrate [ Time:200 ]
A24: Array Process [ Variable:%all_names Type:Remove Duplicates ]
A25: Variable Set [ Name:%Menu_data_apps To:%menu_data_apps Do Maths:Off Append:Off ]
A26: Variable Set [ Name:%All_names To:%all_names(:) Do Maths:Off Append:Off ]

francwalter

unread,
Oct 22, 2015, 10:18:38 AM10/22/15
to Tasker
Am Donnerstag, 22. Oktober 2015 11:29:04 UTC+2 schrieb Rich D:

> ...

I am not a regex guy (hopefully you are) and it will take me some time to get this. But this could be the answer.


 So just this would be something like:
([^|]*%package[^|]*)\|([^|]*%appname[^|]*),
and $1 is then the whole package name and $2 is the apps name ?

I am off now, my partner came back and my time-spare is reduced ;)
Hope I find soon time to test your new way soon :)
Thanks anyway and often!
frank

Rich D

unread,
Oct 24, 2015, 8:32:47 PM10/24/15
to Tasker Google Groups Post


>  So just this would be something like:
> ([^|]*%package[^|]*)\|([^|]*%appname[^|]*),

Yup, that it going,  Thanks...

>

Here is the latest. It seems to be working without error and only takes 3 sec on my device. I have included my entire project on this issue. 

Get Names 2 (333)
A1: Vibrate [ Time:200 ]

A2: Variable Set [ Name:%all_names To:%All_names Do Maths:Off Append:Off ] If [ %All_names !~ \%All_names ]
A3: Run Shell [ Command:ps | grep u0_ | awk '{print $9 ","}' Timeout (Seconds):0 Use Root:On Store Output In:%output Store Errors In: Store Result In: ]
A4: Variable Search Replace [ Variable:%output Search:,([^,]*):[^,]*, Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A5: Variable Search Replace [ Variable:%output Search:\s Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A6: Variable Search Replace [ Variable:%output Search:,su, Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A7: Variable Search Replace [ Variable:%output Search:,[^,]*/[^,]*, Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A8: Variable Search Replace [ Variable:%output Search:,[^,]*:[^,]*, Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A9: Variable Split [ Name:%output Splitter:, Delete Base:Off ]
A10: Array Process [ Variable:%output Type:Remove Duplicates ]
A11: For [ Variable:%package Items:%output(:) ]
A12: Variable Add [ Name:%count Value:1 Wrap Around:0 ]
A13: If [ %all_names !~ *%package* ]
A14: Test App [ Type:Package Name Data:%package Store Result In:%appname Continue Task After Error:On ]
A15: Goto [ Type:Top of Loop Number:1 Label: ] If [ %appname ~ \%appname ]
A16: Variable Set [ Name:%all_names To:,%package|%appname Do Maths:Off Append:On ]
A17: End If
A18: Variable Search Replace [ Variable:%all_names Search:([^|]*%package[^|]*)\|([^|]*,) Ignore Case:On Multi-Line:On One Match Only:On Store Matches In:%temp Replace Matches:Off Replace With: ]
A19: Variable Search Replace [ Variable:%temp1 Search:([^|]*%package[^|]*)\| Ignore Case:On Multi-Line:On One Match Only:On Store Matches In: Replace Matches:On Replace With: ] If [ %temp1 Set ]
A20: Variable Set [ Name:%menu_data_apps To:,%temp1 Do Maths:Off Append:On ]
A21: End For
A22: Vibrate [ Time:200 ]
A23: Flash [ Text:%count Long:On ]
A24: Variable Set [ Name:%Menu_data_apps To:%menu_data_apps Do Maths:Off Append:Off ]
A25: Variable Set [ Name:%All_names To:%all_names Do Maths:Off Append:Off ]
A26: Perform Task [ Name:Run Test Priority:%priority Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:Off ]

Array_Sort_2.prj.xml
Reply all
Reply to author
Forward
0 new messages