Hi Vladimir,
thanks for pointing to the CLIP.EXE and the nice and elegant solution
as all code can be in just a little (global) proc .
Shouldn't that work as well with a simple spawn "cmd /C echo %%pc_text%%%|CLIP"
so we do not have to perform all these "OA..." executables?
TIA, Uli
Background:
The CLIP.EXE is documented at https://www.c3scripts.com/tutorials/msdos/clip.html
On https://superuser.com/questions/231023/windows-script-to-copy-some-text-to-the-clipboard there is a discussion how to avoid the additional Newline with:
EDIT
The main thing is that clip command but as pointed out by Asu, a line like echo abc
will also send a \r\n (which is a new line). If you want to avoid that, then that's a very standard issue solved by replacing echo texttoecho
, with echo|set/p=texttoecho
So C:\>echo|set/p=texttoecho|clip
On https://stackoverflow.com/questions/34934036/copying-to-clipboard-from-txt-file-via-bat-file there is a solution to handle multi-line texts with a temporary file as:
However, please note that you should put double quotes around the filename, as your script will otherwise break if the filename contains spaces.
Also not that you can also use input <
in your code, which instead of piping output from another command, immediately puts the contents into a command. To conclude, the following codes will both work:
@echo off
clip < "c:\Users\Test user\Desktop\paste scripts\ProgramTemplate\ProgramTemplate.txt"
or
@echo off
type "c:\Users\Test user\Desktop\paste scripts\ProgramTemplate\ProgramTemplate.txt" | clip