How to 'stop' all tasks

689 views
Skip to first unread message

PC

unread,
Oct 15, 2014, 5:18:41 PM10/15/14
to tas...@googlegroups.com
I've done some searches, but haven't been able to find the answer to this.  I was just wondering if it's possible to stop all running tasks using the 'Stop' action.  If I don't specify a matching pattern, it only stops the task that the action is called from, but I want to be able to stop every task that is running at the time with a shortcut to the 'stopping' task from my home screen, without having to open Tasker, go into any task, and then hit the 'stop' sign next to the 'execute' button at the bottom left of the task window.

I can't seem to get the pattern matching right, as neither '*' (without the asterix) works, nor any combination of regex matching that I can think of (I'm really bad at regex though).

Does anyone have any suggestions on what pattern I would need to use in order for this to work?  I noticed when a I tried a couple of regex statements that the action would pop up the ! error, and so wasn't a valid use of the statement.

If you're wondering why, I'm trying to use this action in order to stop some runaway tasks.  I need to do some task cleanup, but until I get there, I'd like to be able to stop the running tasks using that home screen shortcut.  The 'stop' action is the last step in the stopping task.

Thanks in advance!

Matt R

unread,
Oct 15, 2014, 6:10:11 PM10/15/14
to tas...@googlegroups.com
If all of your tasks are named they should appear in the %TRUN variable.  Then you could do a for loop to go through all the listed tasks and stop them.  Make sure to include an exception to not stop the "stop all tasks" task.

Matt

Jeremy Harris

unread,
Oct 15, 2014, 6:17:21 PM10/15/14
to tas...@googlegroups.com
This is untested, but i think you'll need to define the name of an individual task to stop...In your case, that'll probably be best to use a variable... Let's call it %runningtask. Then you can loop your stop action... something like:

A1: Variable Set [Name: %tasks To: %TRUN]
A2: Variable Split [Name: %tasks Splitter: ,]
A3: For [Variable: %runningtask Items: %tasks()
A4: Stop [Task: %runningtask]
A5: End For

Jeremy Harris

unread,
Oct 15, 2014, 6:18:43 PM10/15/14
to tas...@googlegroups.com
Lol...Matt beat me to it.

:-)

PC

unread,
Oct 15, 2014, 6:44:18 PM10/15/14
to tas...@googlegroups.com
Ah, nice.  Thanks guys!  I'll try it out and let you know if it doesn't work as expected.
Message has been deleted

Jeremy Harris

unread,
Oct 15, 2014, 7:07:09 PM10/15/14
to tas...@googlegroups.com
Matt's last sentence is really important and I didn't think of it in my example above. There's a few ways to do it.

Mike Wilson

unread,
Oct 15, 2014, 9:44:29 PM10/15/14
to tas...@googlegroups.com
You could also stop everything using Tasker's "Disable' function, but then you'd need to go into the UI and enable Tasker manually.

PC

unread,
Oct 15, 2014, 11:46:01 PM10/15/14
to tas...@googlegroups.com
Looks like it does what I want.  The true test will be when I have a bunch of tasks running.  I managed to build in an exception just using an 'If' statement to match the task name that I didn't want to stop, with a 'Goto' a label after the 'Stop' action, but before the 'For' loop ends.  It looks like this, using Jeremy's example, modified:

A1: Variable Set [Name: %tasks To: %TRUN]
A2: Variable Split [Name: %tasks Splitter: ,]
A3: For [Variable: %runningtask Items: %tasks()
A4: If %runningtask matches 'Stop - All Tasks'
A5: Goto label 'Skip'
A6: End If
A7: Stop [Task: %runningtask]
A8: Label: Skip
A9: End For
A10: Flash 'All tasks stopped'

What is written there is not exported from an actual task, as I just typed out how I built it (so, in other words, don't import this, it probably won't work, heh).

Thanks again guys!

PC

unread,
Oct 16, 2014, 3:00:17 AM10/16/14
to tas...@googlegroups.com
So I managed to do a test, and it works as I was hoping. For those of you who want/need a task like this, here is the actual task description from my phone:

Stop - All Tasks (310)
A1: Button [ Button:Back ]
A2: AutoShortcut [ Configuration:Nova Launcher: Page 1 Package:com.joaomgcd.autoshortcut Name:AutoShortcut Timeout (Seconds):0 ]
A3: Variable Set [ Name:%runningtasks To:%TRUN Do Maths:Off Append:Off ]
A4: Variable Split [ Name:%runningtasks Splitter:, Delete Base:Off ]
A5: For [ Variable:%tasks Items:%runningtasks() ]
A6: If [ %tasks ~ Stop - All Tasks ]
A7: Goto [ Type:Action Label Number:1 Label:Skip ]
A8: End If
A9: Stop [ With Error:Off Task:%tasks ]
<Skip>
A10: Anchor
A11: End For
A12: Morse [ Text:S Frequency:2000 Speed:80 Amplitude:50 Stream:3 ]
A13: Flash [ Text:All tasks stopped... Long:On ]

Enjoy!

Matt R

unread,
Oct 16, 2014, 1:12:36 PM10/16/14
to tas...@googlegroups.com
You could take out A6, A7, A8, and A10 and just add an "if" to the stop action (A9).

Matt

PC

unread,
Oct 17, 2014, 2:16:18 AM10/17/14
to tas...@googlegroups.com
Good catch... I always forget I can do that, and usually end up going back and revising, heh.

Thanks!
Reply all
Reply to author
Forward
0 new messages