中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --
联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟
中国DOS联盟论坛
现在时间是 2026-09-25 16:40
共 47,813 主题排行 / 349,918 发帖 / 今日 0 篇 / 48,274 会员排行
DOS批处理 & 脚本技术(批处理室) » 如何让VBS脚本自动在记事本中输入一行文字
可打印版本  1,876 / 8
第1楼 flandy 发表于 2007-06-24 23:43
初级用户 发帖 40 积分 94
如何让VBS脚本自动在记事本中输入一行文字
让VBS脚本自动在记事本中输入一行文字,让脚本自动输入下面两段小短句

This is the most wonderful day of my life
because I'm here with you now

输入短句后自动关闭记事本,并保存文件名为“test”,关闭记事本可以直接使用组合按键Alt+F4来实现
第2楼 lxmxn 发表于 2007-06-25 00:26
版主 发帖 4,938 积分 11,386
是让它模拟“正在打字输入”的效果么?
第3楼 terse 发表于 2007-06-25 00:29
银牌会员 发帖 946 积分 2,404
搜索一下啊
dim ws
set ws=wscript.createobject("wscript.shell")
str = "This is the most wonderful day of my life$because I'm here with you now"
Num = len(str)
ws.run("notepad.exe")
wscript.sleep 100
for i = 1 to Num
Input = Mid(str, i, 1)
if Input = "$" then Input = vbCr
wscript.sleep 100
ws.sendkeys(Input)
next
WS.SendKeys "^s"
WScript.Sleep 100
WS.SendKeys "test"
WScript.Sleep 100
WS.SendKeys "{ENTER}"
WS.SendKeys "%{f4}"

这个没打字效果
dim ws
set ws=wscript.createobject("wscript.shell")
ws.run("notepad.exe")
wscript.sleep 100
ws.sendkeys "because I'm here with you now"
wscript.sleep 100
WS.SendKeys "{ENTER}"
ws.sendkeys "This is the most wonderful day of my life"
WS.SendKeys "^s"
WScript.Sleep 100
WS.SendKeys "test"
WScript.Sleep 100
WS.SendKeys "{ENTER}"
WS.SendKeys "%{f4}"

[ Last edited by terse on 2007-6-25 at 12:37 AM ]
第4楼 bd123456789 发表于 2007-06-25 22:32
中级用户 发帖 216 积分 360
Originally posted by terse at 2007-6-25 12:29 AM:
搜索一下啊
dim ws
set ws=wscript.createobject("wscript.shell")
str = "This is the most wonderful day of my life$because I'm here with you now"
Num = len(str)
ws.run(& ...



精彩!
第5楼 bd123456789 发表于 2007-06-25 22:32
中级用户 发帖 216 积分 360
Originally posted by terse at 2007-6-25 12:29 AM:
搜索一下啊
dim ws
set ws=wscript.createobject("wscript.shell")
str = "This is the most wonderful day of my life$because I'm here with you now"
Num = len(str)
ws.run(& ...



精彩!
第6楼 kich 发表于 2007-06-26 02:31
中级用户 发帖 168 积分 397
但是按照这种方法,好象不能输入汉字吧!!~
第7楼 flyingphf 发表于 2007-07-01 23:41
中级用户 发帖 142 积分 392
不错啊,要是能输入汉字就更好了
第8楼 enixchen 发表于 2007-08-13 12:33
初级用户 发帖 23 积分 57
可以的
可以输入汉字的
几个月前见过类似代码
希望哪位大大可以再贴出来下
第9楼 zh159 发表于 2007-08-14 10:47
金牌会员 发帖 1,467 积分 3,687
[ 联系联盟系统管理团队 - 中国DOS联盟 - 标准版 ]
Sponsored by ifanr Inc | © 2001–2023