zoukankan      html  css  js  c++  java
  • 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界有一个清闲的世界让我静心的去专研,不求功名利禄,只为心中的那份成就感及自我成长、自我实现的快感。
  • 相关阅读:
    在Power BI报表和仪表板中显示刷新日期时间
    微软Power BI 每月功能更新系列——12月Power BI 新功能学习
    在Microsoft Power BI中创建地图的10种方法
    您应该将报表从Excel转换为Power BI的8个原因
    OBS录制全屏游戏的方法(超好录屏)
    关于Adobe Premiere Pro视音频不同步的解决方法
    Npcap:Nmap项目里一个为Windows而生的嗅探库 Npcap: Nmap Project's packet sniffing library for Windows
    关于被malloc分配内存的指针
    VS2017 高级使用方法
    Npcap环境配置(Winpcap后继者) pcap的一种
  • 原文地址:https://www.cnblogs.com/Automation_software/p/2036928.html
Copyright © 2011-2022 走看看