案例说明

       自动读取Excel表中数据, 根据指定的微信号, 内容, 进行消息发送

效果展示


案例实现

    /*
    版本: Creator 5.1.2
    功能: 微信消息自动发送
    作者: By Hejing
    时间: 2020/8/19

    注意点: 
    1, 启动需要更换wechatPath(微信路径)
    2, res目录中需要添加"接收人微信号.xlsx"信息, 
    模板地址: 链接:https://pan.baidu.com/s/1lXsbTZLaLdWutIHQX3iC0A 提取码:6666 

    */

    // 1,定义变量
    dim iRet = ""
    dim arrayRet = ""
    dim objExcelWorkBook = ""
    dim iPID = ""
    dim objWindow = ""
    dim objUiElement = ""
    dim wechatPath = "C:\\Program Files (x86)\\Tencent\\WeChat\\WeChat.exe"

    // 2, 启动微信
    iPID = App.Run(wechatPath, "0", "1")

    // 3, 绑定或打开excel
    Try
        objExcelWorkBook = Excel.BindBook("接收人微信号.xlsx")    
    Catch e
        objExcelWorkBook = Excel.BindBook(@res"接收人微信号.xlsx")    
    End Try

    // 4, 获取总行数,遍历数据
    iRet = Excel.GetRowsCount(objExcelWorkBook,"Sheet1")
    objWindow = PrintToScreen.CreateWindow({"height":68,"resolution":{"height":768,"width":1366},"width":356,"x":622,"y":359},true)
    PrintToScreen.DrawText(objWindow,"正在发送...请勿触碰",28,[255,0,0])
    For i = 1 To iRet-1 step 1 
        Try
            arrayRet = Excel.ReadRow(objExcelWorkBook,"Sheet1","A"&(i+1))

            #icon("@res:tn7vtisc-q5sr-2pbt-drkf-10571010e6sl.png")
            Keyboard.InputText({"wnd":[{"app":"WeChat","cls":"WeChatMainWndForPC","title":"微信"}],"ctrl":[{"role":"ROLE_SYSTEM_CLIENT","name":"微信"},{"role":"ROLE_SYSTEM_TEXT","name":"搜索"}]},arrayRet[0],true,20,10000,{"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":500,"sKeyModifiers":[],"sSimulate":"message","bValidate":false,"bClickBeforeInput":false})
            Keyboard.Press("Enter", "press", [],{"iDelayAfter":300,"iDelayBefore":200,"sSimulate":"simulate"})
            #icon("@res:1r5hd9m9-2umg-n8uh-gjto-5uf29qa377et.png")
            Keyboard.InputText({"wnd":[{"app":"WeChat","cls":"WeChatMainWndForPC","title":"微信"}],"ctrl":[{"role":"ROLE_SYSTEM_CLIENT","name":"微信"},{"role":"ROLE_SYSTEM_TEXT","name":"输入"}]},arrayRet[1],true,20,10000,{"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":500,"sKeyModifiers":[],"sSimulate":"message","bValidate":false,"bClickBeforeInput":false})
            #icon("@res:o6pejau0-um05-kc07-g1tq-9daigufr6jk4.png")
            Mouse.Action({"wnd":[{"app":"WeChat","cls":"WeChatMainWndForPC","title":"微信"}],"ctrl":[{"role":"ROLE_SYSTEM_CLIENT","name":"微信"},{"role":"ROLE_SYSTEM_PUSHBUTTON","name":"按Enter键发送,按Ctrl+Enter键换行"}]},"left","click",10000,{"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200,"bSetForeground":true,"sCursorPosition":"Center","iCursorOffsetX":0,"iCursorOffsetY":0,"sKeyModifiers":[],"sSimulate":"simulate"})
        Catch
            Continue
        Else
            // pass
        End Try
    Next

    // 5,关闭提示
    PrintToScreen.DrawText(objWindow,"恭喜发送完成",38,[255,0,0])
    Delay(3000)
    PrintToScreen.CloseWindow(objWindow)

results matching ""

    No results matching ""