copy txt file to clipboard

Post your questions and help other users.

Moderator: Martin

farshadmo368
Posts: 31
Joined: 31 May 2018 09:18

copy txt file to clipboard

Post by farshadmo368 » 02 Jun 2018 13:56

Hello I have a txt file like this
x1
x2
x3
x4
.
.
x999
x1000
I want the text to be copied one by one in the clipboard That is, copy x1 first and then x2. Up to x1000, respectively.

And I want to make two different actions
like this

copy x1 to clipboard go to action 1
copy x2 to clipboard go to action 2
copy x3 to clipboard go to action 1
copy x4 to clipboard go to action 2
.....
....
....
copy x999 go to action 1
copy x1000 go to action 2

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: copy txt file to clipboard

Post by Desmanto » 02 Jun 2018 16:09

Hehehe, it seems you need it fast. Unfortunately I am in the middle of transferring my old phone data to new one. Just got my RN5 yesterday, kinda busy migrating data.

It is almost the same as the open pdf, just some different actions. Same init variable file list to get all files. Then use the script to filter the text only, change the extension in the script to "txt".

To open text file and read the content, use Init Variable Text File. The to copy it, use Copy text to Clipboard. But it seems that is not the proper way to do your flow.
Do you really need to copy it to the clipboard before processing? What is the action 1 and action 2? is there a paste() action there? Because you can save some step and make the flow faster by using the text file content directly, rather than copying to clipboard first. We are talking about 1000 files, obviously saving some steps will save a huge amount of time in the end. Or maybe you can do the whole things just in a single script, if your action 1 and 2 is about parsing data.

Got to know what is the detail of action 1 and 2 first. If both of them are separate actions which is not script function, then you can use Condition Execution Count to split them, use 2. So every first execution will result in false, the second execution result in true. Thus execute 1000, 500 will go to true, 500 will go to false respectively. From both of these, loop back to the script until everything is finish.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

farshadmo368
Posts: 31
Joined: 31 May 2018 09:18

Re: copy txt file to clipboard

Post by farshadmo368 » 02 Jun 2018 17:03

Thank you engineer Desmanto,
There is a paste operation,
I do not want to open the file,
I want write to clipboard, And then paste.

like this

write x1 to cliboard,And then paste.
up to x1000

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: copy txt file to clipboard

Post by Desmanto » 02 Jun 2018 17:18

If that so, Init Variable Text File + Copy Text to Clipboard will be a pair to loop. Need to take care of the action 1 and action 2, are they the same, just different app? Or what are the differences that need to be separated?

paste() operation need Control UI, you will need accessibility services to be turned on for Automagic. (Settings > Features & Permissions)
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

farshadmo368
Posts: 31
Joined: 31 May 2018 09:18

Re: copy txt file to clipboard

Post by farshadmo368 » 02 Jun 2018 17:40

automagic accessibility is on.
I just want to know how many TXT files are copied one by one to the clipboard

farshadmo368
Posts: 31
Joined: 31 May 2018 09:18

Re: copy txt file to clipboard

Post by farshadmo368 » 02 Jun 2018 17:45

not work
Attachments
flow_Flow8_20180602_221435.xml
(2.37 KiB) Downloaded 688 times

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: copy txt file to clipboard

Post by Desmanto » 03 Jun 2018 07:59

If you want to know only the number of text file, you only need script. When you use Init Variable File List, files will be populated by all the file names from that folder. You only need to check if it is a text file (end with .txt)

So you only need the script after it, very similar, except you don't need to append "file:///" and encode it anymore.

Code: Select all

txt = newList();
for(i in files)
{
  if(endsWith(i, "txt"))
    addElement(txt, i)
}

txtcount = length(txt);
number of text file inside the folder is txtcount.

If you still need to copy it to clipboard and do something to it, then you only need to use the similar loop from the open pdf version. Except replace the pdf with txt list. And replace the start activity with "Init Variable Text File". This action support direct path, no need to encode URL again.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

farshadmo368
Posts: 31
Joined: 31 May 2018 09:18

Re: copy txt file to clipboard

Post by farshadmo368 » 03 Jun 2018 10:06

hi, not work
Attachments
Screenshot_2018-06-03-14-25-38-314_ch.gridvision.ppam.androidautomagic.png
Screenshot_2018-06-03-14-25-38-314_ch.gridvision.ppam.androidautomagic.png (176.96 KiB) Viewed 16779 times

farshadmo368
Posts: 31
Joined: 31 May 2018 09:18

Re: copy txt file to clipboard

Post by farshadmo368 » 03 Jun 2018 10:45

.txt not copyed to clipboard

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: copy txt file to clipboard

Post by Desmanto » 03 Jun 2018 12:35

The script is the preparation for the list of file, it should not be looped.

Code: Select all

txt = newList();
for(i in files)
{
  if(endsWith(i, "txt"))
    addElement(txt, i)
}
index = 0;
len = length(txt);
As you can see, it is very similar.

The loop start after the script, which is Init Variable Text file.
File : {txt[index]}

The expression part is exactly the same as pdf one, as it is one of the standard method to loop over list.
Init text file to Clipboard.png
Init text file to Clipboard.png (132.66 KiB) Viewed 16752 times
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Post Reply