Skip to content

Instantly share code, notes, and snippets.

@ray1980
Forked from huntagain2008/wechat_bot.vbs
Created January 8, 2022 23:58
Show Gist options
  • Save ray1980/64142f32d3f6d0babdba4b31772d1e56 to your computer and use it in GitHub Desktop.
Save ray1980/64142f32d3f6d0babdba4b31772d1e56 to your computer and use it in GitHub Desktop.
Windows微信桌面端定时发送消息vbs脚本
WeekStr="1,2,3,4,5"
TimeStr="08:00:00"
NameStr="好友或群的备注"
TextStr="36.1"
Function Istime(I_dayofweek,Times)'定时执行
userTime=Split(Times,":")
userHour=userTime(0)
userMinute=userTime(1)
userSecond=userTime(2)
sysTime=Split(Split(Now()," ")(1),":")
sysHour=sysTime(0)
sysMinute=userTime(1)
sysSecond=userTime(2)
I_Istimeout=False
I_judge1=False
I_dowarry=Split(I_dayofweek,",")
For Each daynum In I_dowarry
If Cstr(daynum)=Cstr(Weekday(date)) Then
I_judge1=True
End If
Next
If I_judge1=True Then
If userHour = sysHour And userMinute = sysMinute And userSecond = sysSecond Then
I_Istimeout=True
End If
End If
Istime=I_Istimeout
End Function
Do
wscript.sleep 500
if Istime(WeekStr,TimeStr) = True then'到时间发送
Set ws =CreateObject("wscript.Shell")
Set oExe = ws.Exec("C:\Program Files (x86)\Tencent\WeChat\WeChat.exe")
ws.Run "mshta vbscript:ClipboardData.SetData("&chr(34)&"text"&chr(34)&"," &Chr(34)& NameStr &Chr(34)& ")(close)",0,True'写入剪切板 好友或群的备注
wscript.Sleep 2000
ws.AppActivate oEXE.ProcessID
wscript.sleep 1000
ws.sendKeys "^f"'搜索通讯录
wscript.sleep 1000
ws.sendKeys "^v"'粘贴
wscript.sleep 1000
ws.sendKeys "{ENTER}"
wscript.sleep 1000
ws.Run "mshta vbscript:ClipboardData.SetData("&chr(34)&"text"&chr(34)&"," &Chr(34)& TextStr &Chr(34)& ")(close)",0,True'写入剪切板 要发送的信息
ws.sendKeys "^v"
wscript.sleep 1000
ws.sendKeys "{ENTER}"
Set ws = Nothing
Set oEXE = Nothing
end if
loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment