3
我是vbscript的新手。我想保存使用vbscript打开的Internet Explorer窗口的vbscript拍摄的快照。使用vbscript保存快照
代码加载页面
Dim IE, stateString
Set IE = WScript.CreateObject("InternetExplorer.Application")
ie.toolbar = 1
ie.statusbar = 1
ie.width = 999
ie.height = 500
ie.left = 20
ie.theatermode = false
ie.theatermode = true
ie.theatermode = false
ie.top = 50
ie.navigate("file:///C:\Users\Vinit_Tiwari\Documents\vbscripts\someform.html")
'stateString = cstr(ie.readystate)
waitforload(ie)
ie.visible = 1
Set wshShell = CreateObject("Wscript.Shell")
wshShell.AppActivate "Some Form"
wshShell.SendKeys "% x"
代码执行快照
Dim oWordBasic
set oWordBasic = CreateObject("Word.Basic")
oWordBasic.sendkeys "{prtsc}"
oWordBasic.AppClose "Microsoft Word"
Set oWordBasic = Nothing
Wscript.Sleep 2000
保存快照
dim paint
set paint = wshShell.exec("mspaint")
do while paint.status = 0:loop
wshShell.appactivate("untitled-Paint")'this returns false
Wscript.sleep 500
WshShell.SendKeys "^v"
wscript.sleep 500
wshshell.sendkeys "^s"
wscript.sleep 500
wshshell.sendkeys "d:\test.png"
wscript.sleep 500
wshell.sendkeys "{Enter}"
Set wshshell = Nothing
其实先前打开的IE窗口是有重点和击键发送给ie而不是绘画。那么是否有任何执行AppActivate
的相反工作的功能。
嗨Nilpo,感谢您的回复......但是请您告诉我在AppActivate中传递的正确标题是什么,以便应用程序可以在前台... – codeomnitrix 2012-04-10 11:22:00
这对于每个版本的视窗。您需要打开MS Paint并查看标题栏。 – Nilpo 2012-04-10 14:37:00
其实我使用的是Windows 7,标题栏显示mspaint的'Untitled-Paint',这就是我想要的。 – codeomnitrix 2012-04-11 12:00:41