求一段VBS代码,挺有难度的哦!!!
求一段VBS代码,挺有难度的哦!!!
运行后,每隔一分钟查看一下 http://wpa.qq.com/pa?p=1:123456:4
这个网址(当然,不能调用IE之类的,不能出现什么窗口),(打开后是一个GIF图片,如果QQ在线,则为1.27KB,不在线则为600字节。)
当为1.27KB时则运行OnLine.bat,并依然每隔1分钟执行一次检查,直到检测为600字节(即不在线时)再运行NotOnLine.bat 。然后还是照样每隔1分钟执行一次检查,再次等到为1.27KB时再次运行OnLine.bat,……
如此往复循环。
谢谢!!
[解决办法]
Dim Http As Variant Dim b As Variant Dim fso As Variant Dim BeginTime As Variant Dim objShell As Variant Set objShell = CreateObject("Wscript.Shell") Set Http = CreateObject("MSXML2.XMLHTTP") Do BeginTime = Timer While Timer < BeginTime + 60 DoEvents Wend Http.Open "GET", "http://wpa.qq.com/pa?p=1:123456:4", False Http.Send If Http.readystate <> 4 Then Exit Function End If Set objstream = CreateObject("ADODB.Stream") objstream.Type = 1 objstream.Open Set fso = CreateObject("Scripting.FileSystemObject") If Http.Status = 200 Then objstream.Write Http.responseBody If fso.FileExists("d:\QQ.jpg") Then Call fso.DeleteFile("d:\QQ.jpg", True) End If objstream.SaveToFile "d:\QQ.jpg" Set f = fso.GetFile("d:\QQ.jpg") If f.Size = 600 Then objShell.Run "cmd /c NotOnLine.bat", 1 'objShell.Run "notepad", 1 ElseIf Round(f.Size / 1024, "0.00") = 1.27 Then objShell.Run "cmd /c OnLine.bat", vbHide End If objstream.Close Set objstream = Nothing Set fso = Nothing End If Loop