VBS实现工作任务自动QQ提醒(第二版)

      前段时间在http://www.cnblogs.com/Automation_software/archive/2011/04/13/2010857.html发表了VBS实现工作任务自动QQ提醒,之后对相关功能做了相关的改动,最终代码如下:

Function sendmsg(item_code1,item_code2,item_code3,item_code4,qq_id)
dim Data_Source
Data_Source
="BRT170"
msg
= "有相关工作任务,请及时处理!工单编号为:" rem 发送消息内容
'''''''''''''''''''''''''''''''''''''''''''''''''''
Dim res,cmd,sql
Set res
=createobject("adodb.recordset")
Set cmd
=createobject("adodb.command")
Rem 连接数据库
Dim Connstring
Connstring
="Provider=OraOLEDB.Oracle.1;Password = query ;Persist Security Info=True; User ID = query ; Data Source = "&Data_Source&" ; Server = 172.19.201.170"
Cmd.activeconnection
= Connstring
rem 查询语句

sql
="SELECT wm_concat(app_no) app_no FROM sp_issue a WHERE EXISTS (SELECT 1 FROM sp_process c WHERE c.item_code IN ('"&item_code1&"','"&item_code2&"','"&item_code3&"','"&item_code4&"') AND c.state = '0' AND c.app_no = a.app_no)"
Cmd.CommandText
=sql
Dim returnapp_no
Set res
=Cmd.Execute()

If res.EOF And res.BOF Then
res.Close
Else
If res(
0)<>"" Then
returnapp_no
=Cstr(res(0))
On Error Resume Next
str
=""&msg&""&returnapp_no&""
Set WshShell
=WScript.CreateObject("WScript.Shell")
WshShell.run
"mshta vbscript:clipboardData.SetData("+""""+"text"+""""+","+""""&str&""""+")(close)",0
WshShell.run
"tencent://message/?Menu=yes&uin="&qq_id&"&Site=&Service=200&sigT=2a39fb276d15586e1114e71f7af38e195148b0369a16a40fdad564ce185f72e8de86db22c67ec3c1",0,true
WScript.Sleep
3000
WshShell.SendKeys
"^v"
WshShell.SendKeys
"%s"
WshShell.sendkeys
"{enter}"
WScript.Sleep
1000
WshShell.sendkeys
"%{F4}"
End If
End If
Set res
=Nothing
Set Cmd.activeconnection
=Nothing
Set Cmd
=Nothing
end Function
call sendmsg(
"216","217","218","219","420363096")
call sendmsg(
"216","217","218","219","1743549558")

       将以上代码保存为*.VBS文件。

       在指定时间内间隔时间的运行*.VBS文件,添加另一个VBS文件,代码如下:

Option Explicit
function run(mintime,maxtime,xrun)
dim i,WshShell
Set WshShell
= CreateObject("WScript.Shell" )
WshShell.CurrentDirectory
= "D:\"
i=Hour(time())
if (cint(i)>=mintime and cint(i)<=maxtime) then
Call WshShell.Run(xrun,
1, True):exit function
end
if
set WshShell=nothing
end function

do
dim file
file
="Automatic_notification.vbs"
run
9,22,file
wscript.sleep
15000*60
loop

       将以上代码保存为**.vbs,运行**.vbs即可实现我们的功能。

专注于自动化、性能研究,博客为原创,转载请注明文章来源于:http://www.cnblogs.com/Automation_software/ 只求在IT界有一个清闲的世界让我静心的去专研,不求功名利禄,只为心中的那份成就感及自我成长、自我实现的快感。
原文地址:https://www.cnblogs.com/Automation_software/p/2036928.html