Board logo

标题: 如何让VBS脚本自动在记事本中输入一行文字 [打印本页]

作者: flandy     时间: 2007-6-24 23:43    标题: 如何让VBS脚本自动在记事本中输入一行文字

让VBS脚本自动在记事本中输入一行文字,让脚本自动输入下面两段小短句

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

输入短句后自动关闭记事本,并保存文件名为“test”,关闭记事本可以直接使用组合按键Alt+F4来实现
作者: lxmxn     时间: 2007-6-25 00:26
是让它模拟“正在打字输入”的效果么?
作者: terse     时间: 2007-6-25 00:29
搜索一下啊
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 ]
作者: bd123456789     时间: 2007-6-25 22:32


  Quote:
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(& ...

精彩!
作者: bd123456789     时间: 2007-6-25 22:32


  Quote:
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(& ...

精彩!
作者: kich     时间: 2007-6-26 02:31
但是按照这种方法,好象不能输入汉字吧!!~
作者: flyingphf     时间: 2007-7-1 23:41
不错啊,要是能输入汉字就更好了
作者: enixchen     时间: 2007-8-13 12:33    标题: 可以的

可以输入汉字的
几个月前见过类似代码
希望哪位大大可以再贴出来下
作者: zh159     时间: 2007-8-14 10:47
http://www.cn-dos.net/forum/viewthread.php?tid=30017