detect %WIN ~ "Tasker"

596 views
Skip to first unread message

Benjamin Caldwell

unread,
Apr 7, 2015, 1:05:45 AM4/7/15
to tas...@googlegroups.com
I would like to prevent a certain task from running if I have tasker open.

The task that I want to prevent is a task that opens Pandora whenever %MTRACK is set to '*(live)' (because I don't like to listen to the "live" versions of songs). Anyway tasker automatically opens Pandora and thumbs down the 'live' track for me.


But this can be really annoying if I'm in the middle of working on a Tasker project

So I just want to add an IF statement to the beginning of my thumbs down task that says basically if %WIN ~ Tasker then don't do the auto thumbs down task.


But I don't know how to detect of I have tasker open; %WIN never gets set to "Tasker"

Can any of you think of a workaround for this?


Thanks

Jeremy Harris

unread,
Apr 7, 2015, 6:28:45 AM4/7/15
to tas...@googlegroups.com
I made a workaround for detecting Tasker. Before I share, you should know that the FAQ states some good reasons for not doing this...

I use this task to launch Tasker the way I want:

Launch Tasker (371)
A1: [X] Secure Settings [ Configuration:Tasker: MyAccessibilityService - Enabled Package:com.intangibleobject.securesettings.plugin Name:Secure Settings Timeout (Seconds):0 ]
A2: Profile Status [ Name:Shake - Kill Current App Set:Off ]
A3: Profile Status [ Name:Proximity - Kill Current App Set:Off ]
A4: Launch App [ App:Tasker Data: Exclude From Recent Apps:Off Always Start New Copy:On ]
A5: Launch App [ App:Detect Tasker Data: Exclude From Recent Apps:Off Always Start New Copy:On ]


At A5 above, I launch an app called Detect Tasker, which is a kid apk that I exported from Tasker. It's just this one task:

Detect Tasker (355)
Run Both Together
A1: Variable Set [ Name:%newline To:
Do Maths:Off Append:Off ]
A2: Variable Set [ Name:%space To: Do Maths:Off Append:Off ]
A3: Run Shell [ Command:ps Timeout (Seconds):0 Use Root:Off Store Output In:%apps Store Errors In: Store Result In: ]
A4: Variable Split [ Name:%apps Splitter:net.dinglisch.android.taskerm Delete Base:Off ]
A5: Variable Split [ Name:%apps1 Splitter:%newline Delete Base:Off ]
A6: Variable Set [ Name:%last To:%apps1(#) Do Maths:Off Append:Off ]
A7: Variable Set [ Name:%taskerpidline To:%apps1(%last) Do Maths:Off Append:Off ]
A8: Variable Split [ Name:%taskerpidline Splitter:%space Delete Base:Off ]
A9: Variable Set [ Name:%taskerpid To:%taskerpidline4 Do Maths:Off Append:Off ]
A10: Run Shell [ Command:cat /proc/%taskerpid/oom_adj Timeout (Seconds):0 Use Root:Off Store Output In:%oom Store Errors In: Store Result In:%Aresult ]
A11: [X] Flash [ Text:%oom Long:Off ]
A12: Wait [ MS:0 Seconds:1 Minutes:0 Hours:0 Days:0 ]
A13: Goto [ Type:Action Number Number:1 Label: ] If [ %oom < 2 ]
A14: Write File [ File:DetectTasker/shutdownlog.txt Text:%DATE %TIME Append:On Add Newline:On ]


I run that as an apk because it loops continuously and I want the runlog clean in Tasker. Notice the Write File action... it triggers this profile every time it detects that Tasker has closed:

Profile: File MOD - Tasker Closed (356)
Event: File Modified [ File:DetectTasker/shutdownlog.txt ]
Enter: Exit Tasker (357)
A1: If [ %MyCameraFolders !Set ]
A2: [X] Secure Settings [ Configuration:Tasker: MyAccessibilityService - Disabled Package:com.intangibleobject.securesettings.plugin Name:Secure Settings Timeout (Seconds):0 ]
A3: Profile Status [ Name:Proximity - Kill Current App Set:On ] If [ %PoximityKill ~ 1 ]
A4: Profile Status [ Name:Shake - Kill Current App Set:On ] If [ %ShakeKill ~ 1 ]
A5: Secure Settings [ Configuration:Air Gesture - Enabled Package:com.intangibleobject.securesettings.plugin Name:Secure Settings Timeout (Seconds):0 ]
A6: Secure Settings [ Configuration:> Air Browse - Enabled Package:com.intangibleobject.securesettings.plugin Name:Secure Settings Timeout (Seconds):0 ]
A7: Secure Settings [ Configuration:> Air Scroll - Enabled Package:com.intangibleobject.securesettings.plugin Name:Secure Settings Timeout (Seconds):0 ]
A8: Secure Settings [ Configuration:> Quick Glance - Enabled Package:com.intangibleobject.securesettings.plugin Name:Secure Settings Timeout (Seconds):0 ]
A9: Secure Settings [ Configuration:Multi Window - Enabled Package:com.intangibleobject.securesettings.plugin Name:Secure Settings Timeout (Seconds):0 ]
A10: Secure Settings [ Configuration:Smart Scroll - Enabled Package:com.intangibleobject.securesettings.plugin Name:Secure Settings Timeout (Seconds):0 ]
A11: Secure Settings [ Configuration:Smart Stay - Enabled Package:com.intangibleobject.securesettings.plugin Name:Secure Settings Timeout (Seconds):0 ]
A12: Vibrate Pattern [ Pattern:200,200,200,200,200,200 ]
A13: End If


You can modify a little bit in everything here to make it work for you.

Rich D

unread,
Apr 7, 2015, 9:14:21 AM4/7/15
to Tasker Google Groups Post

> But I don't know how to detect of I have tasker open; %WIN never gets set to "Tasker"

Not sure why, it gets set on my device. What tasker version are you running?

This would most likely not be  reliable anyway. There are several window values within the tasker UI one of them is %WIN. I would recommend Jeremy's approach. 

easiuser

unread,
Apr 7, 2015, 10:49:42 AM4/7/15
to tas...@googlegroups.com
I am certain Jeremy's approach will work but you might try a simpler approach for your specific needs.  Create a task that sets a global variable %TaskerEdit to 1 and then launches Tasker.  Put a shortcut to this on your home page and use this to start Tasker.  Create a profile for %WIN ~ Home (or whatever your launcher sets) with an entry task Variable Clear %TaskerEdit. 

You now have a global variable you can test to prevent the other task from running and gets reset every time you exit to your home screen.

Benjamin Caldwell

unread,
Apr 7, 2015, 11:44:41 AM4/7/15
to tas...@googlegroups.com

Thanks, for the ideas guys.  (I'm using Tasker Version: 4.6u3m)

easiuser, I went with your approach because it only took me a minute to set up.  And its working great so far.

Thanks

Jeremy Harris

unread,
Apr 7, 2015, 2:23:30 PM4/7/15
to tas...@googlegroups.com
Thanks @easiuser! I forgot that reason I needed to take this unusual approach in the first place was because I was testing a project that needed to Go Home and get the %WIN value, the return to Tasker.

Lol, everything I posted above is way beyond necessary for the op use! Glad you caught that!
Reply all
Reply to author
Forward
0 new messages