| 关键词: nbsp wscript output writeline then createobject end talk set 对方 |
这阵子终于可以经常碰电脑拉!!!刚尝试,脚本写的不完整,比如一些输出输入到后来没有 .close这个脚本是刚测试成功,所以只带有聊天部分,网络配置得事先按要求配置好。需要环境:两台电脑互相开启了目录共享并映射给对方, 映射盘符为X: 共享目录下建立 chat 文件夹,里面放入下面的 “talktest.vbs ” 其中一方执行,脚本提示 Quote: 等待响应..待对方执行后 Quote: .双方连接完成! (我是通过删除或建立某个指定文件来判断的^_^,没啥好方法了,因为情况可能有很多种。。。先打开a: 如果存在x 则等待x消失 , b后打开: 如果存在x 则删除x这样子来响应的。不存在则反) 之后输入字符,对方应该是可看到的,我这边的另一台电脑是可以。要结束的时候输入 end 并回车~ 对方也会得到结束的提示。 CODE: [Copy to clipboard] set wsx=createobject("wscript.shell")if wscript.arguments.count = 0 then wsx.run _ "cmd /c mode con cols=80 lines=25 &cscript //logo " _ &wscript.scriptname & " 0",3 wsx.run _ "cmd /c mode con cols=80 lines=5 &title Inputbox &cscript //nologo " _ &wscript.scriptname & " 1",3 wscript.quitelseif wscript.arguments(0) = 1 then call readinput() wscript.quitelseif wscript.arguments(0) = 0 then call scroll() wscript.quitend ifsub readinput()bok="x:\chat\talk.x"btalk="x:\chat\talk.txt"aok="talk.x"atalk="talk.txt"set fs=createobject("scripting.filesystemobject")if fs.fileexists(aok) then fs.deletefile(aok)else fs.createtextfile(aok)end ifset writex=fs.createtextfile(atalk,true)do wscript.stdout.write "say:" set inp=wscript.stdin inpinfo=inp.readline writex.writeline inpinfoloop until inpinfo = "end"wscript.sleep 1000wscript.quitend subsub scroll()bok="x:\chat\talk.x"btalk="x:\chat\talk.txt"aok="talk.x"atalk="talk.txt" set wsx=createobject("wscript.shell") set fs=createobject("scripting.filesystemobject") set output=wscript.stdout for i = 1 to 3 output.writeline "" next output.write "等待响应" if fs.fileexists(bok) then call wait(bok,true) '因存在而等待 else call wait(bok,false) '因不存在而等待 end if if fs.fileexists(aok) then fs.deletefile(aok) else fs.createtextfile(aok) end if output.writeline "双方连接完成! " &vbcrlf & "对方: " &vbcrlf call wait(btalk,false) '因不存在而等待 set talkx=fs.opentextfile(btalk,1) set oursx=fs.opentextfile(atalk,1) do if talkx.atendofstream then wscript.sleep 800 else info=talkx.readline output.writeline info end if if oursx.atendofstream = false then if oursx.readline = "end" then output.writeline "Closing..." wscript.sleep 1000 wscript.quit end if end if loop until info = "end" output.writeline "Script: He was close the chatbox. " output.writeline "Script: Input 'end' (at smallbox) and press enter to exit..." while oursx.atendofstream = true wscript.sleep 800 wend wscript.quitend subsub wait(filename,have) set fs=createobject("scripting.filesystemobject") set output=wscript.stdout while fs.fileexists(filename) = have output.write "." wscript.sleep 1000 wendEnd sub |
|
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系
[邮箱地址] 删除
|