send clip board content to text file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
batchcc
Posts: 139
Joined: 17 Aug 2015 06:05
Contact:

send clip board content to text file

#1 Post by batchcc » 24 Oct 2015 08:34

Is it possible to send text from the clip board to a text file from a batch file I tried
Clip> C:\Users\user\1.text
But it didn't work is is it possible to do this?

npocmaka_
Posts: 516
Joined: 24 Jun 2013 17:10
Location: Bulgaria
Contact:

Re: send clip board content to text file

#2 Post by npocmaka_ » 24 Oct 2015 08:46

Code: Select all

for /f "usebackq tokens=* delims=" %i in (`mshta "javascript:Code(close(new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(clipboardData.getData('Text'))));"`) do @echo %i>C:\Users\user\1.text 
Last edited by npocmaka_ on 24 Oct 2015 09:12, edited 1 time in total.

batchcc
Posts: 139
Joined: 17 Aug 2015 06:05
Contact:

Re: send clip board content to text file

#3 Post by batchcc » 24 Oct 2015 08:54

Npocmaka I am sorry but it's not working on my computer note I am running windows Vista don't know if that helps ?

npocmaka_
Posts: 516
Joined: 24 Jun 2013 17:10
Location: Bulgaria
Contact:

Re: send clip board content to text file

#4 Post by npocmaka_ » 24 Oct 2015 09:04

Have you ran this through batch file or from command line?
If you want to run this from batch double the %-es.

batchcc
Posts: 139
Joined: 17 Aug 2015 06:05
Contact:

Re: send clip board content to text file

#5 Post by batchcc » 24 Oct 2015 09:10

I would like to run it from a batch file but I tried running it through cmd and it didn't work it sent the text type clip /? For usage into the text file.
Last edited by batchcc on 02 Apr 2016 04:31, edited 1 time in total.

npocmaka_
Posts: 516
Joined: 24 Jun 2013 17:10
Location: Bulgaria
Contact:

Re: send clip board content to text file

#6 Post by npocmaka_ » 24 Oct 2015 09:14

batchcc wrote:I would like to run it from a batchance file but I tried running it through cmd and it didn't work it sent the text type clip /? For usage into the text file.

So this is what you have in the clip board - the CLIP help.

Try to copy something else.

batchcc
Posts: 139
Joined: 17 Aug 2015 06:05
Contact:

Re: send clip board content to text file

#7 Post by batchcc » 24 Oct 2015 09:18

No I had copied my question the the clip board and it sent the clip help to the text file instead.

npocmaka_
Posts: 516
Joined: 24 Jun 2013 17:10
Location: Bulgaria
Contact:

Re: send clip board content to text file

#8 Post by npocmaka_ » 24 Oct 2015 12:22

small test:

Code: Select all

@echo off

echo ##--##|clip

for /f "usebackq tokens=* delims=" %%i in (
   `mshta "javascript:Code(close(new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(clipboardData.getData('Text'))));"`
) do (
 echo cntent of the clipboard:
 echo %%i
)



output :

cntent of the clipboard
##--##



The ways to access clipboard without external binaries are :
1)"InternetExplorer.Application" activex object through vbscript or jscript and use clipboardData.getData(..) method.Though will require admin permissions to create invisible instance of IE
2)mshta (which is in fact internet explorer) through clipboardData.getData(..) method. Hta window will flash for a moment , though with Code(..) flashing is minimized.
3) with .net and Clipboardclass

npocmaka_
Posts: 516
Joined: 24 Jun 2013 17:10
Location: Bulgaria
Contact:

Re: send clip board content to text file

#9 Post by npocmaka_ » 26 Oct 2015 04:59


Post Reply