在VBScript程序运行时关闭它

时间:2017-04-30 14:57:36

标签: vbscript message

(这是一个.vbs程序)我正在尝试为一个程序制作一个消息机器人,但我想出了一个问题,如果你设置的时间太长,并设置了数量消息太高,您无法轻松停止该程序,并且必须一遍又一遍地处理您的消息,直到完成为止。有没有办法在运行时添加一个选项来阻止输入消息?     这是代码:

set shell = createobject ("wscript.shell")

strtext = inputbox ("Type the message you like to type")
strtimes = inputbox ("How many times would you like to type this message?")
strspeed = inputbox ("How fast do you like to message? (1000 = one per sec, 100 = 10 per sec etc)")
strtimeneed = inputbox ("How many SECONDS do you need to get to your input box?")
If not isnumeric (strtimes & strspeed & strtimeneed) then
msgbox "You entered something else then a number on Times, Speed and/or Time need. Closing program"
wscript.quit
End If
strtimeneed2 = strtimeneed * 1000
do
msgbox "You have " & strtimeneed & " seconds to get to your input area where you are going to message."
wscript.sleep strtimeneed2
shell.sendkeys ("Hello" & "{enter}")
for i=0 to strtimes
shell.sendkeys (strtext & "{enter}")
wscript.sleep strspeed
Next
shell.sendkeys ("Bye" & "{enter}")
wscript.sleep strspeed * strtimes / 10
returnvalue=MsgBox ("Want to send the messages again with the same info?",36)
If returnvalue=6 Then
Msgbox "Ok Messagebot will activate again"
End If
If returnvalue=7 Then
msgbox "Messaging is shutting down"
wscript.quit
End IF
loop

1 个答案:

答案 0 :(得分:0)

您可以设置一个快捷方式来终止所有正在运行的wscript.exe进程。在桌面上单击鼠标右键,在上下文菜单中选择New - Shortcut:

context menu - New - Shortcut

输入%comspec% /c taskkill /f /im wscript.exe作为位置,然后点击下一步

location

输入您喜欢的名称,然后单击完成

name

您也可以在快捷方式属性中指定热键。