'根据反馈,修改如下:
'说明:Monitor过程是专为30秒后自动关闭窗口,进入锁机状态而作。如果你不要此功能,就可以把这部分去掉。这时的代码就很少了。
'对于这个问题,你如果还有其他疑问,请发消息给我。
Dim WshShell,PWD,i
Dim fso,tempfolder
Set fso = CreateObject("Scripting.FileSystemObject")
Set tempfolder = fso.GetSpecialFolder(2)
Set WshShell = CreateObject("Wscript.Shell")
Monitor
do while true
Wscript.Sleep 30*60*1000
If not fso.fileexists(tempfolder & "\~Tmp01") Then
fso.createtextfile(tempfolder & "\~Tmp01").Close
End If
for i=1 to 3
PWD = InputBox("系统将锁机,输入密码取消", "锁机提示")
if PWD="123456" or PWD=" /" then exit for
next
If fso.fileexists(tempfolder & "\~Tmp01") Then
fso.DeleteFile tempfolder & "\~Tmp01"
End If
'请根据实际修改下面的密码及键盘锁的按键、密码等
if PWD<>"123456" then
msgbox "正式进入锁机状态!"
WshShell.Run "d:\lock.exe"
Wscript.Sleep 1000
WshShell.AppActivate "键盘锁"
WshShell.SendKeys "123"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "123"
WshShell.SendKeys "{ENTER}"
end if
loop
'以下代码为通用代码,请不要修改
Sub Monitor()
Set tf = fso.CreateTextFile(tempfolder & "\~tmp.vbs", True)
tf.WriteLine("Dim WshShell,fso, tempfolder")
tf.WriteLine("Set fso = CreateObject(" & chr(34) & "Scripting.FileSystemObject" & chr(34) & ")")
tf.WriteLine("Set WshShell = CreateObject(" & chr(34) & "Wscript.Shell" & chr(34) & ")")
tf.WriteLine("Set tempfolder = fso.GetSpecialFolder(2)")
tf.WriteLine("Do While not fso.fileexists(tempfolder & " & chr(34) & "\~Tmp02" & chr(34) & ")")
tf.WriteLine("If fso.fileexists(tempfolder & " & chr(34) & "\~Tmp01" & chr(34) & ") Then")
tf.WriteLine("Wscript.sleep 30000")
tf.WriteLine("If fso.fileexists(tempfolder & " & chr(34) & "\~Tmp01" & chr(34) & ") Then")
tf.WriteLine("fso.DeleteFile tempfolder & " & chr(34) & "\~Tmp01" & chr(34))
tf.WriteLine("WshShell.AppActivate " & chr(34) & "锁机提示" & chr(34))
tf.WriteLine("WshShell.SendKeys " & chr(34) & " /" & chr(34))
tf.WriteLine("Wscript.Sleep 500")
tf.WriteLine("WshShell.SendKeys " & chr(34) & "{ENTER}" & chr(34))
tf.WriteLine("End If")
tf.WriteLine("End If")
tf.WriteLine("Loop")
tf.WriteLine("fso.DeleteFile tempfolder & " & chr(34) & "\~Tmp02" & chr(34))
tf.WriteLine("objWord.Quit")
tf.Close
WshShell.Run tempfolder & "\~tmp.vbs"
End Sub
set ws = createobject("wscript.shell")
do
x = 1:y = 1
do
a = inputbox("系统将锁机,请输入密码")
wscript.sleep 30*1000
ws.sendkeys "~"
if a = "" or a = false then x = 0
if a <> 123 then
y = y +1
loop until y = 3
if a <> 123 then x = 0
if x = 0 then ws.run "d:\lock.exe"