Text selection changed 4.0

Share and discuss your flows and ideas with other users.

Moderator: Martin

Post Reply
User avatar
Hit
Posts: 91
Joined: 20 Jan 2020 11:31

Text selection changed 4.0

Post by Hit » 31 Jul 2020 02:21


Today, I want to share this flow: Text selection changed

What we have here:
  • This flow is an example which allow you store any text you selected in a global variable and reuse it later
  • Additionally, proving the power of Automagic with Trigger UI Event
  • Introduce some benefit of using Trigger UI Event Text selection changed
    Which I cannot find in Tasker even with plugin Autoinput

This is also a prototype of a flow for people to use, edit to achieve their own purpose.

The flow can be shortened to only two Block, but for everyone to understand, I made it longer.

I also add many Notes in this flow so you can understand what I did and what for (and some minor comment too).

Give it a try.
flow_Text_selection_changed_2020.xml
(7.23 KiB) Downloaded 1885 times

A picture of the flow:
Text selection changed.png
Text selection changed.png (609.92 KiB) Viewed 42754 times
Last edited by Hit on 31 Jul 2020 11:50, edited 5 times in total.

User avatar
Hit
Posts: 91
Joined: 20 Jan 2020 11:31

Re: Text selection changed 4.0

Post by Hit » 31 Jul 2020 02:34


Notes:
  • This is an example. You can edit it for your purposes (or make a copy).
  • You should delete the Condition in the middle or remove the connection to it, or any time you 'click' on text (even text is not selected) or when you change position of text cursor in editable field, it still save the text in the global variable. Unless you want that.

Last edited by Hit on 31 Jul 2020 22:55, edited 11 times in total.


rupesh
Posts: 9
Joined: 29 Jan 2020 05:44

Re: Text selection changed 4.0

Post by rupesh » 08 Oct 2020 03:02

When executing this flow this happens:
After clicking on a paragraph on a webpage it gives a whole bunch of words...I wanted to get the first word only...eg father in this screenshot below.Please can you guide me edit the flow??

Of course when I select a single word or more by highlighting it...one or more word is given.But i dont want to 'select' a word..I wish to click on a paragraph or a line and it should give me first word...or the word I clicked on.

Or I could specify what place I could get a word from..eg word no 4..or number 5th etc.

Is this even possible?

I want the first word of a paragrap be stored in a global variable and reuse it later or maybe the word i click on get stored in global variable.


Please help!!!

Image

User avatar
Hit
Posts: 91
Joined: 20 Jan 2020 11:31

Re: Text selection changed 4.0

Post by Hit » 08 Oct 2020 06:30


Hello rupesh, I understand your question.

When you click on a paragraph (not select), it may get the whole paragraph and store it in global_textselection according to my flow.

In the case you want only the first word, you can use Regex in Action Control UI or Script with the variable global_textselection and store the first word you want in a new variable.

In the following example, I create a variable called first_word, but you can change it if you want, like global_first_word if you need to store the word in a global variable.

New code:

first_word = findAll(global_textselection, "^\\S*")[0];
//findAll(s, pattern)
//Returns a list of all matched values in s of regex pattern.
//Because the result of findAll() function is a list so [0] get the first element in the list, and is the first word

Just add a new Action to the flow and use the code, follow the instruction above and you will get the goal. I hope this will work.


rupesh
Posts: 9
Joined: 29 Jan 2020 05:44

Re: Text selection changed 4.0

Post by rupesh » 08 Oct 2020 11:43

Thank you!! I will update how it went.

rupesh
Posts: 9
Joined: 29 Jan 2020 05:44

Re: Text selection changed 4.0

Post by rupesh » 08 Oct 2020 13:32

Update:working fine.

I am curious if there is a way to get the word clicked on , into a variable without selecting, highlighting??

Maybe mapping x,y coordinate of the spot to the word there.
I have no idea how it would work just a vauge idea...
Could you explain if it is doable please?
Thanks!

User avatar
Hit
Posts: 91
Joined: 20 Jan 2020 11:31

Re: Text selection changed 4.0

Post by Hit » 09 Oct 2020 03:10


Only with Automagic, I think it cannot. Even with plugin, it's still too complicated, hard and take times to think about.
So sorry, I can not help you with that

Post Reply