Detect 'any' touch on screen

5,138 views
Skip to first unread message

Oon-Ee Ng

unread,
Apr 23, 2012, 10:45:10 PM4/23/12
to Tasker
Pent,

I think this was answered before, but would like your confirmation. Is
there a possibility to detect that the screen 'was touched'? At any
point, in any way. I was thinking a full-screen transparent scene
might do it (but that would not allow the touch to reach the app
below)?

V Oz

unread,
Apr 24, 2012, 2:08:43 AM4/24/12
to tas...@googlegroups.com
try in Secure Settings script to grep getevent output for touchscreen device and return something form script. In tasker wait event Set variable which returned.

Oon-Ee Ng

unread,
Apr 24, 2012, 3:08:06 AM4/24/12
to tas...@googlegroups.com

Thanks much! For reference, after a bit of playing around in adb, this
is what I have:-

getevent -c 1 /dev/input/event2

This basically watches for the first event from /dev/input/event2
(touchscreen events on my SGS2).

TW

unread,
Apr 24, 2012, 3:42:47 AM4/24/12
to tas...@googlegroups.com
nice idea!
thanks for sharing
Message has been deleted

Robin Dean

unread,
Mar 12, 2013, 1:01:43 PM3/12/13
to tas...@googlegroups.com
Please excuse my reopening of this thread. I'm trying to do the same thing on a Samsung Stratosphere. The script needs to be different. How do I find out what it should be?

GermainZ

unread,
Mar 12, 2013, 2:52:17 PM3/12/13
to tas...@googlegroups.com
Run this in a terminal emulator:
getevent

Touch your screen and note which event you want (event1, event2, etc) then tweak the command.

James Davis

unread,
Jun 4, 2013, 11:17:01 AM6/4/13
to tas...@googlegroups.com
I'm confused. Are you using this as a context somehow or are you using it as an action?

Matt R

unread,
Jun 4, 2013, 1:34:43 PM6/4/13
to tas...@googlegroups.com
Depends how you need to use it. It could be set up to be used as a blocking action or as a context. What are you trying to do?

Matt

spj

unread,
Jun 4, 2013, 3:12:52 PM6/4/13
to tas...@googlegroups.com
I have a custom screen timeout profile using the wait action then calling the app screen off. This allows me to have screen timeouts of les than 7 seconds. I'd love to be able to have an event that could set a variable in order for me to cancel my countdown if the screen is touched.

Matt R

unread,
Jun 4, 2013, 3:43:37 PM6/4/13
to tas...@googlegroups.com
Just create a named task (e.g. Touched) that does the run shell action with the getevent command above. Then before the wait, do a perform task to start the Touched task and then after the wait do a test If %TRUN ~ *,Touched,*

Matt

spj

unread,
Jun 4, 2013, 4:51:58 PM6/4/13
to tas...@googlegroups.com
So to make sure I'm right. Perform task named touched. Then wait 5 Seconds. Then If TRUN ~ touched. Load app Screen off. Finally end if?

Matt R

unread,
Jun 4, 2013, 6:31:17 PM6/4/13
to tas...@googlegroups.com
Make sure to include the asterisks and commas. Check out pattern matching in the user guide to understand why this is important.

Matt

spj

unread,
Jun 4, 2013, 8:16:01 PM6/4/13
to tas...@googlegroups.com
Ok. Thanks so much for the help. I'll see what I can setup. Appreciate it.

James Davis

unread,
Jun 5, 2013, 10:57:16 AM6/5/13
to tas...@googlegroups.com
Thanks for all of your help, unfortunately I can't get it to work the way I think it should. I do have experience with pattern matching, programming and some Tasker use just to put that out there. Etiher I am setting it up wrong, or I didn't properly explain what I want to do.
 
What I'm attempting to do is to have a shorter display timeout using Tasker's wait action and an external app call Screen Off. I would also like to be able to have that timer reset every time I touch the screen just like the system display timeout. 
 
When you load the app all it does is turn the screen off. I know the app works with my device and with Tasker because I use it in another Tasker task that works flawlessly.
 
I have set up a task named "Touched" that uses the Secure Settings Plugin to run command
getevent -c 1 /dev/input/event2
 
Next I have a profile with an orientation face up context the task section is as follows
 
Perform Task named Touched
Wait 3 seconds
If %TRUN~*,Touched,*
Load App app Screen Off If %FACEUP(the variable I set when orientation if face up)~yes
End If
 
When I lay my phone face up the countdown starts and when it's over the screen goes off, however, it always goes off. No matter how many times I tap the screen the task still finishes. The only way it stops is if I change the orientation of the phone. Could anyone help out with this?

JosDaBoss

unread,
Jun 5, 2013, 11:36:59 AM6/5/13
to tas...@googlegroups.com
Then you would have to make a profile that checks the %TRUN~*,Touched,* like every second and reset the timer. Don't think that's very battery friendly.

Bob Hansen

unread,
Jun 5, 2013, 11:48:31 AM6/5/13
to tas...@googlegroups.com
I have done some experimenting on my Droid RAZR HD (rooted) stock 4.1.2. I am using terminal emulator and found that the getevent command suggested does not respond to any screen touch. I can touch repeatedly and there is no response. Finally after some random time something other than a screen touch occurs and that response is shown and the getevent command terminates.
However, if I change the command to 
getevent -c 1 /dev/input/event1 
it does respond.
I would suggest you install a terminal emulator on your phone and verify that the getevent command is responding to a screen touch.
Message has been deleted

James Davis

unread,
Jun 5, 2013, 12:12:00 PM6/5/13
to tas...@googlegroups.com
Well I would only have to check after the countdown begins as the only reason to monitor is to stop the countdown. The countdown is only activated when I put my phone face up.
 
Also @Bob I have input the script into the terminal and a touch is registered as soon as and only when I touch the screen.

Matt R

unread,
Jun 5, 2013, 12:32:31 PM6/5/13
to tas...@googlegroups.com
Check the run log to see when Touched is finishing in relation to your other task. Maybe it's a task priority issue.

Matt

James Davis

unread,
Jun 5, 2013, 12:51:16 PM6/5/13
to tas...@googlegroups.com
You just helped me realize how to get it to work. I'll post what worked, but first how you got me to it. Your statement made me realize that the script should be running until I touch the screen (didn't know how I missed that before lol) That being the case, the simple or easy solution would be to check if the task is still running (which you basically told me but again I didn't get it at the time). Since my revelation told me that what I had set up should be working and it wasn't I decided to take a slightly different approach.
 
The Secure Settings terminal allows users to past variables to Tasker. So what I ended up doing is before I run the script in the Touched task I put a variable clear %Touched. After that i set the script to set %Touched to the output of the script. This way I can monitor if the %Touched is set. It worked immediately.
 
Do you see any potential problems with me doing it this way? Again thanks everyone for all your help.

Matt R

unread,
Jun 5, 2013, 1:53:49 PM6/5/13
to tas...@googlegroups.com
Should be fine. Seems like it should work without going through secure settings though (Tasker's built-in run shell action also allows the output to be put in a variable).

Matt

Eli Tarvin

unread,
Oct 21, 2013, 9:28:50 PM10/21/13
to tas...@googlegroups.com
Ive gotten the the Touched task created with sending the getevent2 to %TRUN, however, I'm not sure what to add to each of the items in the "Test" action? ANy help would be great. All I need is for a task to not run if the screen is touched, obviously without me having to actually touch the screen. 

zohar...@gmail.com

unread,
Feb 10, 2014, 4:05:56 PM2/10/14
to tas...@googlegroups.com
hello,
I found this thread some days ago and implemented this in my tasker.
All was great until I did a restart to my HTC ONE.
After the restart the screen moved from /dev/input/event3 to /dev/input/event5
I changed the task to
/dev/input/event5, but then after another restart it was back to 3 :(
How can I know the dev of screen with in tasker? is there some alias to it?

Thanks,
   Zohar

saha...@gmail.com

unread,
Aug 3, 2015, 4:47:35 AM8/3/15
to Tasker
i am not understand clearly , so kindly send step by step procedure >>>> 

M@xF@ctor

unread,
Nov 9, 2017, 3:57:03 PM11/9/17
to Tasker
Profile: Screen OFF when Face Up (431)
Priority: 1 Restore: no
State: Display State [ Is:On ]
State: Not Call [ Type:Any Number:* ]
Event: Variable Set [ Variable:%Status_Orientation Value:face up User Variables Only:Off ]
Application: Not Smart Launcher Pro
Enter: Screen OFF On Face Up (432)
A1: [X] Flash [ Text:Touch Long:Off ] If [ %Touch Set ]
A2: Variable Clear [ Name:%Touch Pattern Matching:Off Local Variables Only:Off ]
A3: Run Shell [ Command:getevent -c 1 /dev/input/event1 Timeout (Seconds):7 Use Root:On Store Output In:%Touch Store Errors In: Store Result In: Continue Task After Error:On ]
A4: Stop [ With Error:Off Task: ] If [ %SCREEN ~ off ]
A5: Stop [ With Error:Off Task: ] If [ %Status_Orientation !~ face up ]
<IF YOU ARE HERE FACE IS UP BUT PHONE IS TOUCHED SO LOOP&LOOK AGAIN FOR IDLE>
A6: Goto [ Type:Action Number Number:1 Label: ] If [ %Touch Set ]
A7: Secure Settings [ Configuration:Lock Device Timeout (Seconds):0 ]
Reply all
Reply to author
Forward
0 new messages