中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-09-25 07:03
47,813 topics / 349,918 posts / today 1 new / 48,274 members
DOS批处理 & 脚本技术(批处理室) » Word wrap issue
Printable Version  2,332 / 21
Floor1 enixchen Posted 2007-04-27 04:41
初级用户 Posts 23 Credits 57
How to achieve automatic line breaks in input text? For example, xxxxxxxx newline yyyyyyyy >1.tx The generated text is XXXXXXX YYYYYYY
Floor2 xiamin223 Posted 2007-04-27 04:48
新手上路 Posts 2 Credits 4
@echo off
:s
set /p l=
echo %l%>>1.txt
cls
goto s
Floor3 lxmxn Posted 2007-04-27 06:12
版主 Posts 4,938 Credits 11,386
To enixchen:

First time using VBS to solve a problem, please bear with me.
Floor4 enixchen Posted 2007-04-27 06:21
初级用户 Posts 23 Credits 57
echo dim ws>>12.vbs
echo str = "Sorry girl:$I think I...$don't love you!">>12.vbs
echo Num = len(str)>>12.vbs
echo set ws=wscript.createobject("wscript.shell")>>12.vbs
echo ws.run("notepad.exe")>>12.vbs
echo wscript.sleep 200>>12.vbs
echo ws.appactivate "无标题 - 记事本>>12.vbs
echo wscript.sleep 500>>12.vbs

echo for i = 1 to Num>>12.vbs
echo Input = Mid(str, i, 1)>>12.vbs
echo if Input = "$" then Input = vbCr>>12.vbs
echo wscript.sleep 500>>12.vbs
echo ws.sendkeys(Input)>>12.vbs
echo next>>12.vbs

I also got it done, using ECHO````Sweat, but it will write repeatedly```
Floor5 enixchen Posted 2007-04-27 06:36
初级用户 Posts 23 Credits 57
echo dim ws>>12.vbs
echo str = "Sorry girl:$I think I...$don't love you!">>12.vbs
echo Num = len(str)>>12.vbs
echo set ws=wscript.createobject("wscript.shell")>>12.vbs
echo ws.run("notepad.exe")>>12.vbs
echo wscript.sleep 200>>12.vbs
echo ws.appactivate "无标题 - 记事本">>12.vbs
echo wscript.sleep 500>>12.vbs

echo for i = 1 to Num>>12.vbs
echo Input = Mid(str, i, 1)>>12.vbs
echo if Input = "$" then Input = vbCr>>12.vbs
echo wscript.sleep 500>>12.vbs
echo ws.sendkeys(Input)>>12.vbs
echo next>>12.vbs


start 12.vbs

taskkill /f /im notepad.exe

del 12.vbs


The problem of repeated writing is also solved````
Sweat, first end the Notepad process and then delete the file

```But``
Is there a way for this program to automatically save as a TXT file after outputting
don't love you!
Don't save manually
Looking forward to the expert~
Floor6 lililulula Posted 2007-04-27 06:42
中级用户 Posts 138 Credits 302
The building owner wants to automatically wrap lines and output content to a text file. Actually, echo XXXXX>1.txt, echo YYYY>>1.txt, ....... or vbs can all solve it. The building owner's meaning may be to wonder whether there are carriage return characters in the script, and as for this problem, I don't know either.
Floor7 zh159 Posted 2007-04-27 07:07
金牌会员 Posts 1,467 Credits 3,687
Originally posted by enixchen at 2007-4-26 17:21:
echo dim ws>>12.vbs
echo str = "Sorry girl:$I think I...$don't love you!">>12.vbs
echo Num = len(str)>>12.vbs
echo set ws=wscript.createobject("wscript.shell&quo ...

I just made this VBS for demonstration, so I didn't add the part to close Notepad
Floor8 enixchen Posted 2007-04-27 11:21
初级用户 Posts 23 Credits 57
Elder upstairs, how to implement saving and closing????
Floor9 lxmxn Posted 2007-04-28 00:29
版主 Posts 4,938 Credits 11,386
Originally posted by enixchen at 2007-4-26 22:21:
How to implement saving and closing? ? ?

I don't understand what you mean.

After writing to a file with VBS, it saves automatically.
Floor10 lxmxn Posted 2007-04-28 00:34
版主 Posts 4,938 Credits 11,386
```@echo off&Setlocal EnableDelayedExpansion
for /f "delims=" %%a in (1.txt) do (
set str=%%a
set str=!str:换行=$_!
exit|cmd/kprompt !str!>>new_.txt
)
```
Floor11 enixchen Posted 2007-04-28 02:39
初级用户 Posts 23 Credits 57
dim ws
str = "Sorry girl:$I think I...$don't love you!"
Num = len(str)

set ws=wscript.createobject("wscript.shell")
ws.run("notepad.exe")
wscript.sleep 200
ws.appactivate " 记事本 "
wscript.sleep 500

for i = 1 to Num

Input = Mid(str, i, 1)

if Input = "$" then Input = vbCr

wscript.sleep 500

ws.sendkeys(Input)

next

Your question is about the code by zh159. How to achieve creating a text file named XX.TXT, automatically inputting, and then automatically saving?
Floor12 lxmxn Posted 2007-05-13 07:27
版主 Posts 4,938 Credits 11,386
Floor13 huihua2008 Posted 2007-05-13 13:06
新手上路 Posts 3 Credits 5
I'm here, push it up
Floor14 slore Posted 2007-05-13 13:54
铂金会员 Posts 2,478 Credits 5,212
Dim WShell,fso,file
Set WShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set file = fso.OpenTextFile("Outext.txt",2,True)

str = "Sorry girl:$I think I...$don't love you!"

file.Write Replace(str,"$",vbCrLf)
file.Close

Res = MsgBox("文本已经生成,是否现在查看?",1,"提示")

If Res = 1 Then WShell.run "Outext.txt"

Set file = Nothing
Set fso = Nothing
Set WShell = Nothing
Floor15 flyinspace Posted 2007-05-13 14:06
银牌会员 Posts 517 Credits 1,206
It's very simple?

@echo off

echo Please enter the content you want to input. Press Ctrl+Z key to end.
copy con 1.txt

pause

In this way, a few lines of code can be done.
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023