早教吧 育儿知识 作业答案 考试题库 百科 知识分享

对VBS代码熟悉的来!帮我注解下.坐等setWshShell=WScript.CreateObject("WScript.Shell")Setdm=CreateObject("dm.dmsoft")WshShell.run("cmd.exe")Whilehwnd=0hwnd=dm.FindWindow("","cmd.exe")wscript.sleep100Wenddmret=dm.GetWindowRect(hw

题目详情
对VBS代码熟悉的来!帮我注解下.坐等
set WshShell = WScript.CreateObject("WScript.Shell")
Set dm= CreateObject("dm.dmsoft")
WshShell.run("cmd.exe")
While hwnd=0
hwnd = dm.FindWindow("","cmd.exe")
wscript.sleep 100
Wend
dm_ret=dm.GetWindowRect(hwnd,x1,y1,x2,y2)
msgbox hwnd & vbcrlf & x1 & "," & y1 & "," & x2 & "," & y2,"打开了DOS窗口"
dm.SetWindowText hwnd,"test"
'hwnd = dm.GetMousePointWindow()
dm_ret = dm.BindWindow(hwnd,"normal","windows","windows",0)
'dm.MoveWindow hwnd,0,0
dm.KeyPress 13
dm.sendstring hwnd,"cls&@echo off"
dm.KeyPress 13
for i=0 to 8
str = "cls&color " & i & (i+1)
dm.sendstring hwnd,str
dm.KeyPress 13
wscript.sleep 200
next
dm.sendstring hwnd,"echo 3秒倒计时&pause"
dm.KeyPress 13
wscript.sleep 3000
dm.KeyPress 13
dm.KeyPress 13
dm.sendstring hwnd,"cls&start notepad&exit"
dm.KeyPress 13
dm_ret = dm.UnBindWindow()
wscript.sleep 500
hwnd1 = dm.FindWindow("","无标题 - 记事本")
if hwnd1>0 then
hwnd = dm.FindWindowEx(hwnd1,"Edit","")
dm_ret = dm.BindWindow(hwnd,"normal","windows","windows",0)
msgbox hwnd1 & vbcrlf & x1 & "," & y1 & "," & x2 & "," & y2 & vbcrlf & "确定后,最小化记事本!","打开了记事本"
dm_ret = dm.SetWindowState(hwnd1,2)
dm.sendstring hwnd,"看到了吧,这个是被最小化过后发送的字符串!" & vbcrlf
wscript.sleep 500
dm_ret = dm.SetWindowState(hwnd1,5)
dim arr
str = "怎 么 样 ,神 奇 ,祝 你 好 运 "
arr = split(str," ")
if hwnd>0 then
for i=0 to ubound(arr)
dm.sendstring hwnd,arr(i)
wscript.sleep 200
next
end if
dm_ret = dm.UnBindWindow()
else
msgobx "未能打开记事本,失败!"
end if
▼优质解答
答案和解析
WshShell.run("cmd.exe") //调用命令行程序
While hwnd=0
hwnd = dm.FindWindow("","cmd.exe")// 循环直到得到命令行程序的窗口句柄
wscript.sleep 100
Wend
dm_ret=dm.GetWindowRect(hwnd,x1,y1,x2,y2)//得到窗口大小位置参数
msgbox hwnd & vbcrlf & x1 & "," & y1 & "," & x2 & "," & y2,"打开了DOS窗口"//显示对话框
dm.SetWindowText hwnd,"test"//更改窗口标题
dm.sendstring hwnd,"cls&@echo off" 向窗口发送字符串信息
下面都差不多了,原理一样