Skip to content

Instantly share code, notes, and snippets.

@troilus
Forked from huntagain2008/wechat_bot.vbs
Created January 21, 2022 11:39
Show Gist options
  • Save troilus/73021ed2bebb641ae279309eb601c307 to your computer and use it in GitHub Desktop.
Save troilus/73021ed2bebb641ae279309eb601c307 to your computer and use it in GitHub Desktop.
Windows微信桌面端定时发送消息vbs脚本
WeekStr = "2,3,4,5,6"'Monday, Tuesday, Wednesday, Thursday, Friday
someTime = #9:19:01 AM#
NameStr = "WeChat Friend Name or WeChat Group Name"
TextStr = "36.1"
Function Istime(I_dayofweek,Times)'Scheduled Execution
userHour=Hour(Times)
userMinute=Minute(Times)
userSecond=Second(Times)
Dim ThisMoment
ThisMoment = Now()
sysHour=Hour(ThisMoment)
sysMinute=Minute(ThisMoment)
sysSecond=Second(ThisMoment)
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,someTime) = True then'Schedule message to send
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'WeChat Friend Name or WeChat Group Name Write to clipboard
wscript.Sleep 2000
ws.AppActivate oEXE.ProcessID
wscript.sleep 1000
ws.sendKeys "^f"'Search Contacts
wscript.sleep 1000
ws.sendKeys "^v"'Paste
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'The text to be send Write to the clipboard
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