Copy Typed String and Paste it into a Text Field

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
alleypuppy
Posts: 82
Joined: 24 Apr 2011 19:20

Copy Typed String and Paste it into a Text Field

#1 Post by alleypuppy » 29 Apr 2011 21:33

Hello. Is there a way to type a string into a batch file and have that typed string copied into some text field. I'm assuming that you would use VBScript, but I don't know how to do it. Thanks for any help!

shiva
Posts: 18
Joined: 11 Jul 2011 03:53

Re: Copy Typed String and Paste it into a Text Field

#2 Post by shiva » 15 Sep 2011 01:15

Hi,
I have created a batch script to read and save a string entered.
I don't know Vb script but i have tried to use in java,

a.bat:

set /p choice="enter string"
echo you have entered %choice%
java a.class %choice%

a.java file should be designed in such a way that it take a argument and place that argument
in that required text field,

thank you
shiva shankar

nitt
Posts: 218
Joined: 22 Apr 2011 02:43

Re: Copy Typed String and Paste it into a Text Field

#3 Post by nitt » 15 Sep 2011 16:06

alleypuppy wrote:Hello. Is there a way to type a string into a batch file and have that typed string copied into some text field. I'm assuming that you would use VBScript, but I don't know how to do it. Thanks for any help!


Filling in a text field with VBScript/JScript on the internet is rather easy, but for an unexperienced person, it can feel rather hard. But there is an easier way that even the noobiest of the noobs could understand. This way is just simply to just use the "sendkeys" method to fill in some kind of a field. For example:

VBScript:

Code: Select all

@echo off
echo createobject("wscript.shell").sendkeys("I love pie!") > ~tmp.vbs
start notepad
ping 0 -n 1 > nul
~tmp
ping 0 -n 1 > nul
del ~tmp.vbs
pause


JScript:

Code: Select all

@echo off
echo new ActiveXObject("wscript.shell").sendkeys("I love pie!") > ~tmp.js
start notepad
ping 0 -n 1 > nul
~tmp
ping 0 -n 1 > nul
del ~tmp.js
pause


I use the "ping" command just to space it out, I've had experiences where if you don't do that then it will disallow you to delete the file at the end.

And "sendkeys" basically just controls your keyboard. Use something like "^a" to select all text in a field then use "^c" to copy it, and like "^p" to paste it.

Ranguna173
Posts: 104
Joined: 28 Jul 2011 17:32

Re: Copy Typed String and Paste it into a Text Field

#4 Post by Ranguna173 » 21 Sep 2011 10:18

Here is a simple batch code that saves variables in files

Code: Select all

@echo off
echo What do you want to write on the file?
echo (first line)
set /p fl=
cls
echo What do you want to write on the file?
echo (second line)
set /p sl=
cls
echo What do you want to write on the file?
echo (third line)
set /p tl=
cls
echo Type the name of the file.
set /p name=
echo %fl%>%name%
echo %sl%>>%name%
echo %tl%>>%name%
cls
echo A file named %name% as been created in this directory.
pause
exit

Post Reply