HomeTaskerTasker: Having fun with Tasker Post-It notes

Tasker: Having fun with Tasker Post-It notes

Send a sticky note to another device!

I love creating little projects that aren’t solving any problems but work well as great tutorials. AutoTools Web screens just got updated with Post-It notes – the sticky notes that are displayed as an overlay, so I thought I create a project that replicates the original purpose of the notes: leaving more or less useful messages for your friends and family.

In this tutorial, I will show you how to create a “chat” behaviour where you can send the note from one Android device to another and reply to received messages. And the best bit is? You can just fling the note to send it to another device! How cool is that?

The video that comes with this write up contains an unedited version of this project. You will find there my workflow and better illustration of how I create and troubleshoot projects like this. This write up is based on cleaned up and streamlined version of that project.

Creating a “chat” with Tasker Post-It notes

The new AutoTools Web Screen preset allows you to create a sticky note. The overlay then can be edited and dismissed with an X or a swipe. You can create a note in any colour, control the text size and colour and the note’s dimensions. They look cute and I could imagine a couple of uses for it.

In my project, I want to write a note on one phone, then for the same note to appear on another. At the same time I want the person to have the ability to reply to the message too, essentially recreating a cute chat conversation using Tasker Post-It notes.

Creating Tasker Post-It notes is simple. All you need is to download the AutoTools Web screen preset Sticky Notes and specify a couple of parameters:

  • title  (%PIC_name)
  • text (%PIC_message)
  • colour (%PIC_color)
  • text colour (optional set to #000000)
  • dimensions  (%PIC_height & %PIC_width)

As I’m trying to replicate the chat, there are 2 behaviours I have to cover. Creating the Tasker Post-It note, and displaying the note that has been sent over to our device.

Creating a new Tasker Post-It note

To create a Post-it note, I need to declare the values specified previously. Since some of them will be permanent, I will run a setup task as run task action.

Setup
TASKER TASK - PIC Setup
PIC Setup 
	Abort Existing Task
	A1: AutoTools Dialog [ Configuration:Dialog Type: Input
		Title: Your name
		Title Alignment: Left
		Text Size: 20
		Input Type: Text
		Output Variable: attext
		Dim Background: true
		Top Margin: 16
		Bottom Margin: 16
		Bottom Buttons Top Margin: 16
		Bottom Buttons Bottom Margin: 16
		Cancelable: true
		Turn Screen On: true Timeout (Seconds):60 ] 
	A2: Variable Set [ Name:%PIC_name To:%attext 
		Recurse Variables:Off Do Maths:Off Append:Off ] 
	A3: AutoTools Dialog [ Configuration:Dialog Type: Input
		Title: AR device name
		Title Alignment: Left
		Text Size: 20
		Input Type: Text
		Output Variable: attext
		Dim Background: true
		Top Margin: 16
		Bottom Margin: 16
		Bottom Buttons Top Margin: 16
		Bottom Buttons Bottom Margin: 16
		Cancelable: true
		Turn Screen On: true Timeout (Seconds):60 ] 
	A4: Variable Set [ Name:%PIC_target To:%attext 
		Recurse Variables:Off Do 		Maths:Off Append:Off ] 
	A5: Wait [ MS:0 Seconds:3 Minutes:0 Hours:0 Days:0 ] 
	A6: AutoTools Dialog [ Configuration:Dialog Type: Color Timeout (Seconds):60 ] 
	A7: Variable Set [ Name:%PIC_color To:%atcolor 
		Recurse Variables:Off Do Maths:Off Append:Off ] 
	A8: Variable Set [ Name:%PIC_setup To:1 
		Recurse Variables:Off Do Maths:Off Append:Off ]     

This task will launch only once, (the %PIC_setup will assure this) setting the preferred values for %PIC_name, %PIC_target (more on that later) and %PIC_color. I used 2 AutoTools dialog actions to input text and one for the colour picker. I had issues with getting the colour picker to work correctly but adding a wait action for the popup to load – fixed it.

Once the values are set, the tasks set the %PIC_setup to one, and next time you want to create a Post-It note, the dialogs are not displayed.

Creating a new Post-It note
TASKER TASK - PIC Create Note
PIC Create Note 
	A1: Perform Task [ Name:PIC Setup 
		Priority:%priority Parameter 1 (%par1): 
		Parameter 2 (%par2): 
		Return Value Variable: 
		Stop:Off ] 
		If [ %PIC_setup eq 0 ]
	A2: AutoTools Web Screen [ Configuration:Screen Preset: Sticky Note
		Display Mode: Overlay
		Close Overlay ID: Postit
		Source: /storage/emulated/0/AutoTools/sticky_note/page.html
		Toast Duration: 5000
		Background Color: #00FFEBEE
		Width: 150
		Height: 150
		Gravity: Center
		Animation: Slide In From Top
		Overlay Id: Postit
		Show Duration: 500
		Hide Duration: 250
		Drag: Draggable Anywhere
		Drag Movements: All Directions
		Fling To Dismiss: All Directions
		Command On Close: PIC_closed
		Title: %PIC_target
		Text: ...
		Color: %PIC_color
		Text Color: #000000
		Text Size: 16vw
		Command On Change: PIC_textchange
		Direct Input Mode: true Timeout (Seconds):30 ]     

I created the web screen and predefined a couple of parameters. Since at this stage I’m going to create a note myself, I can hardcode the default values. Everything else but name and colour is predefined.

There are two AutoApps commands that I have to define too. These will fire up each time a note is closed or the text in the Post-It note has changed. I’m going to use these to send the message over to another device. The command on close is PIC_closed and the command on text change is PIC_textchange.

Displaying incoming Tasker Post-It note

TASKER PROFILE - Received Note Info
Profile: PIC Receive Note Info 
	Event: AutoRemote [ Configuration:PostIt (regex) ]
Enter: PIC Display Note (16)
	A1: Variable Set [ Name:%PIC_target To:%arsendername 
		Recurse Variables:Off Do Maths:Off Append:Off ] 
	A2: AutoTools Web Screen [ Configuration:Screen Preset: Sticky Note
		Display Mode: Overlay
		Close Overlay ID: %arcomm1
		Source: /storage/emulated/0/AutoTools/sticky_note/page.html
		Toast Duration: 5000
		Width: 160
		Height: 160
		Gravity: Center
		Animation: Slide In From Top
		Overlay Id: %arcomm1
		Show Duration: 500
		Hide Duration: 250
		Drag: Draggable Anywhere
		Drag Movements: All Directions
		Fling To Dismiss: All Directions
		Command On Close: PIC_closed
		Title: %arcomm1
		Text: %arcomm2
		Color: %arcomm3
		Text Color: #000000
		Text Size: 16vw
		Command On Change: PIC_textchange
		Direct Input Mode: true Timeout (Seconds):30 ]     

The sticky note will be sent to another device via AutoRemote. I can generate a config string that will contain all the information to create a new note. The AutoRemote string will look like this:

PostIt=:=%PIC_name=:=%PIC_message=:=%PIC_color=:=%PIC_height=:=%PIC_width

I have added the information about the dimensions so you could also define the size of the Post-It note. I’m not using it in my project but the framework is there for you.

[appbox googleplay com.joaomgcd.autoremote]

The AutoRemote even responds to  “PostIt” filter and triggers the task responsible for displaying the message and the sticky note. For the most part, the action is similar to the “Create Note” task, but the pre-defined values are replaced by the data coming in the %arcomm() array.

VariableAutoRemote variable
%PIC_name%arcomm1
%PIC_message%arcomm2
%PIC_color%arcomm3
%PIC_height%arcomm4
%PIC_width%arcomm5
%PIC_target%arsendername 

In addition to that, the %arsendername contains the name of the AR device from which the message had been received. That information is used to send the reply back. I used variable set action to set get the recipient ready for the reply.

If you are going to use the dimensions, you can use the variables as per the table above. I used the fixed dimension of 160×160 in my setup.

Commands –  save the new message

TASKER PROFILE - Command Text
Profile: PIC Command Text 
	Event: AutoApps Command [ Configuration:Command Filter: PIC_textchange
		Regex: true ]
		Enter: PIC Command Text 
	A1: Variable Set [ Name:%PIC_replied To:1 
		Recurse Variables:Off Do Maths:Off Append:Off ] 
	A2: Variable Set [ Name:%PIC_message To:%aacomm 
		Recurse Variables:Off Do Maths:Off Append:Off ]     

When a text of the note is changed, we can send a command which will contain the command and the new text. It will look like this:

PIC_textchange=:=this is the new message

This is already formatted to be used with replies, and the text of the reply will be stored in the AutoApps variable %aacomm. I created the AutoApps event which simply responds to the PIC_textchange.

You will also notice, that I have added a new variable %PIC_replied I will cover this in the next paragraph.

Commands – close|send

TASKER PROFILE - Command Close
Profile: PIC Command Close
	Event: AutoApps Command [ Configuration:Command Filter: PIC_closed
	Regex: true ]
	Enter: PIC Command Close
		A1: AutoRemote Message [ Configuration:Recipient: %PIC_target						
			Message:PostIt=:=%PIC_name=:=%PIC_message=:=%PIC_color=:=%PIC_height=:=%PIC_width 
			Timeout (Seconds):200 ] 
			If [ %PIC_replied eq 1 ]
		A2: Flash [ Text:Note sent Long:Off ] If [ %PIC_replied eq 1 ]
		A3: Variable Set [ Name:%PIC_replied To:0 
			Recurse Variables:Off Do Maths:Off Append:Off ] 
		A4: Variable Clear [ Name:%PIC_message 
			Pattern Matching:Off Local Variables Only:Off ]     

Due to AutoTools limitation, close and swipe to close is recognized as the same behaviour. It’s a bit of a bummer as I love the swipe to send gesture. I had to come up with a workaround to keep the gesture, otherwise, you would be stuck in an eternal loop or replying to the messages without the ability to close the note without the sending.

In the final version, I check if the message has been modified. If so, then the message is sent and the note is closed. If the message wasn’t modified, the profile simply closes the message without sending it. To achieve this, I created a new variable %PIC_replied which is set to active (1) when the replied has been typed. This way I have a distinction between sending and closing using a single AutoApps command: PIC_closed.

To send the message, I use AutoRemote and pass the string if the message has been modified. This works for replies and for creating new notes. Otherwise, I close the note and reset the value of the %PIC_replied to 0. Lastly, I’m clearing things up by removing info from the %PIC_message.

Conclusion

You can have plenty of fun with the notes. I know I’m not solving an existing problem or creating the new exciting chat with Tasker, but the tutorial comes with a couple of neat tricks how to tackle the limitations of the Web Screens with a variable. I hope this will be a great learning material for you.

Project Download

Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.

PayPal

Nothing says "Thank you" better than keeping my coffee jar topped up!

Patreon

Support me on Patreon and get an early access to tutorial files and videos.

image/svg+xml

Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

New to Tasker?

Tasker Quick Start – Getting started with Tasker

0
From newb to not so newbie in 10 min

Best Tasker Projects

How to use Raspberry PI as WOL (wake on lan) server

0
While you could wake up your PC from a mobile directly, having a dedicated server capable of doing so is the best solution. The reason is simple. You can hook up as many devices as you wish with a single endpoint. This is why Raspberry Pi is perfect for this.

How to wake on LAN computers and put it to sleep with Power Menu,...

0
How to Wake on LAN properly via Android, Alexa, Google Assistant and Web

7 awesome Bluetooth keyboard shortcuts for Android

0
7 unique Android shortcuts that you can add to any Bluetooth keyboard.

Smart overnight charging with Tasker

0
Still keeping your phone plugged in overnight? Try smarter overnight charging with this profile

One thing that Join app can’t do and how to fix it with Tasker

0
It's not possible to share the clipboard automatically between join accounts registered to 2 different emails. But you can fix this with tasker.

Essential Guides

Tasker: Seconds into DD:HH:MM:SS (dynamic)

0
It's time to.... ok it's a pun, but I will show you how to master time and convert seconds to DD:HH:MM:SS dynamically

4 ways to organise Tasker projects

0
Keep your Tasker tidy!

A better way to store Tasker credentials

0
The more clever way of managing credentials

Annoyed with dozens of AutoApps populating your app drawer? Here is a fix!

0
Clear your app drawer from the clutter in seconds

Putting AutoTools pie chart to a good use – SSID logger

0
Who wants a piece of the pie (chart)?