Last active
January 21, 2022 11:39
-
-
Save huntagain2008/9376bd5a9c35ff5e7a3c387d7833e3fc to your computer and use it in GitHub Desktop.
Windows微信桌面端定时发送消息vbs脚本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
注意vbs一般用ANSI编码