|
'On Error Resume Next
'Shift —— +;Ctrl —— ^;Alt —— %
sub sleeping
wscript.sleep 1
end sub
sub testshell
dim path
dim wsh
set wsh=createobject("wscript.shell")
'name=inputbox("请输入你的名字","名称")
'magbox name,,"你的名称是"
'wsh.run "calc",,true
wsh.run "notepad"
Wsh.AppActivate "无标题 - 记事本" //定位光标,后面是标题框的名称
wscript.sleep 1
wsh.sendkeys ("5")
wsh.sendkeys "%s" //组合键
wsh.sendkeys "^(sc)" //同时按ctrl,s和c
wsh.sendkeys "{+}" //特殊的键值
WshShell.SendKeys "{x 10}" //输入10个x
end sub
sub testcreatefolder
dim fs
set fs=wscript.createobject("scripting.filesystemobject")
if(fs.folderexists("c:\temp")) then
s="is availabe"
else
s="not exist"
set folder=fs.createfolder("c:\temp")
end if
msgbox s,,"状态"
end sub
sub testcopyfolder(x,y)
dim fs1
set fs1=wscript.createobject("scripting.filesystemobject")
fs1.copyfolder x,y,true
end sub
sub testdeletefolder
dim fs2
set fs2=wscript.createobject("scripting.filesystemobject")
fs2.deletefolder("c:\temp")
fs2.deletefolder("d:\temp")
end sub
sub testmovefolder
'testcreatefolder
dim fs3
set fs3=wscript.createobject("scripting.filesystemobject")
fs3.movefolder "c:\temp","d:\"
end sub
sub testfoldermethod
dim fs4
set fs4=wscript.createobject("scripting.filesystemobject")
testcreatefolder
set f=fs4.getfolder("c:\temp")
'f.delete
f.copy "d:\",true
'f.move "d:\" //没有权限
end sub
function testcalc()
dim wsh
set wsh=wscript.createobject("wscript.shell")
'wsh.run "notepad"
wsh.run "calc"
wscript.sleep 1000
wsh.appactivate "计算器"
'wsh.Appactivate "无标题 - 记事本"
wsh.sendkeys "5{+}5{=}"
end function
call testcalc()
Dim fso,fs
Set fso=WScript.CreateObject("scripting.filesystemobject")
If fso.FileExists("c:\ok1.txt")<>True Then
Set fs=fso.CreateTextFile("c:\ok1.txt")
Else
MsgBox "ok1.txt is exists",,"状态"
End If
Set wr=fso.OpenTextFile("c:\ok1.txt",2,True)
wr.Write("你好,这个是的一段话,下面是一个空行")
wr.WriteBlankLines(1)
wr.WriteLine("这段话会作为一行显示1")
wr.WriteLine("这段话会作为一行显示2")
wr.WriteLine("这段话会作为一行显示3")
wr.Close
Set rd=fso.OpenTextFile("c:\ok1.txt",1,True)
If rd.AtEndOfLine<>True Then
rd.Read(2)
skip(2)
End If
If rd.AtEndOfStream<>True Then
rd.ReadLine
rd.SkipLine(1)
End If
rd.ReadAll
rd.Close |
评分
-
查看全部评分
|