VBS利用QQ签名远程控制电脑,注意修改其中的配置部分代码- '/*////////////////////配置//////////////
- Dim CMDStr(3)
- QQUIN="397607622" '用来控制电脑的QQ号
- '自定义指令消息
- CMDStr(0)="关机"
- CMDStr(1)="显示消息"
- CMDStr(2)="测试"
- '/*//////////////////////////////////////
- 'ON ERROR RESUME NEXT
- Set HTTP=wscript.createobject("Microsoft.XMLHTTP")
- Set ASO=CreateObject("ADODB.Stream")
- Sub CheckCmdLine
- EmotURLStr=GetURLCode("http://taotao.qq.com/vc1/qz_space/def?uin="&QQUIN)
- EmotStr=MyRegExp("item_text"">\s+(.*)\s+</div>",EmotURLStr) '获取最后的心情签名
- Select Case EmotStr
- Case CMDStr(0)
- '关机:
- 'ShutDownWindow
- Case CMDStr(1)
- '自定义函数
- Case CMDStr(2)
- '自定义函数
- End Select
- Wscript.Sleep 30000 '大约30S重复检测QQ签名设置
- Call CheckCmdLine() '循环调用
- End Sub
- Call CheckCmdLine()
- '/*/////////////////////////////////////////////////////////
- '*MadeTime: 2009-10-21
- '*LastModify: 2009-10-21
- '*功能: 获取指定网页源代码
- '*参数: 网页地址
- '**********************************************************
- Function GetURLCode(URL)
- HTTP.open "GET",URL,true '发送网页地址;
- HTTP.send
- For i=1 To 10 '循环检测10次,每次0.5秒
- if HTTP.readystate=4 then '数据接收成功;
- Exit For
- End IF
- Wscript.sleep 500
- Next
- IF not HTTP.Readystate=4 then
- Msgbox "网络连接超时",vbInformation+vbokonly,"手机控制电脑"
- Self.quit
- End IF
- SourceStr=HTTP.ResponseBody '变量接收传回的数据
- Temp=Bytes2Str(SourceStr,"utf-8")
- CharSet=MyRegExp("charset=['""]?([a-zA-Z0-9\-]+)['""]",Temp)
- IF CharSet="" Then CharSet="gb2312"
- GetURLCode=Bytes2Str(SourceStr,CharSet)
- End Function
- '/*/////////////////////////////////////////////////////////
- '*MadeTime: 2009-10-21
- '*LastModify: 2009-10-21
- '*功能: 根据charset值转换网页数据
- '*参数: 待处理数据;CharSet类型
- '**********************************************************
- Function Bytes2Str(Body,Cset)
- With ASO
- .Type = 1
- .Mode =3
- .Open
- .Write body
- .Position = 0
- .Type = 2
- .Charset=Cset
- Bytes2str=.ReadText
- .Close
- End With
- End Function
- '/*/////////////////////////////////////////////////////////
- '*MadeTime: 2009-10-21
- '*LastModify: 2009-10-21
- '*功能: 提取内容正则表达式
- '*参数: 正则表达式;待处理数据对象
- '**********************************************************
- Function MyRegExp(Patrn,Strng)
- Set RegEx1=New RegExp
- With RegEx1
- .Pattern = Patrn
- .IgnoreCase=True
- .Global=True
- End With
- Set Matches =RegEx1.Execute(strng)
- IF Matches.Count>0 then
- MyRegExp=Matches(0).subMatches(0)
- Else
- MyRegExp=""
- End IF
- End Function
- '/*/////////////////////////////////////////////////////////
- '*MadeTime: 2009-10-21
- '*LastModify: 2009-10-21
- '*功能: 定时关机
- '**********************************************************
- Sub ShutDownWindow()
- strComputer = "."
- Set objWMIService = GetObject("winmgmts:" _
- & "{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer & "\root\cimv2")
- Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
- For Each objOperatingSystem in colOperatingSystems
- ObjOperatingSystem.Win32Shutdown(1)
- Next
- End Sub
-
- Set HTTP=Nothing
- Set ASO=Nothing
复制代码
|