' 手写函数_MessageBox
' 手写函数_CreateRandomizedText
' By: PY-DNG
' 注:使用函数MessageBox必须同时声明CreateRandomizedText函数
Function CreateRandomizedText(pwdlen) ' 生成随机文本函数,参数为文本长度
On Error Resume Next
Final = ""
letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
LLength = Len(letters)
For i = 1 To pwdlen
Randomize
rdnum = Int(LLength * Rnd) + 1
Final = Final & Mid(letters,rdnum,1)
Next
CreateRandomizedText = Final
End Function
Function MessageBox(Content,Icon,Title,DisplayTime) ' 参数:信息框内容,图标(同Msgbox),窗口标题,显示时长
On Error Resume Next
Content = Replace(Content,Chr(13),""" & Chr(13) & """)
Content = Replace(Content,Chr(10),""" & Chr(10) & """)
MsgFilePath = SelfFolderPath & CreateRandomizedText(5) & ".vbs"
ExecFilePath = SelfFolderPath & CreateRandomizedText(5) & ".vbs"
MSGFileContent = "CreateObject(""Scripting.FileSystemObject"").DeleteFile Wscript.ScriptFullName" & Chr(13) & Chr(10) & "Msgbox """ & Content & """," & CStr(Icon) & ",""" & Title & """"
If DisplayTime < 0 Then
ExecFileContent = "CreateObject(""Scripting.FileSystemObject"").DeleteFile Wscript.ScriptFullName" & Chr(13) & Chr(10) & "CreateObject(""Wscript.Shell"").Run Chr(34) & """ & MsgFilePath & """ & Chr(34)"
Else
ExecFileContent = "CreateObject(""Scripting.FileSystemObject"").DeleteFile Wscript.ScriptFullName" & Chr(13) & Chr(10) & "Set MsgProcess = CreateObject(""Wscript.Shell"").Exec(""wscript.exe "" & Chr(34) & """ & MsgFilePath & """ & Chr(34))" & Chr(13) & Chr(10) & "Wscript.Sleep " & Cstr(DisplayTime) & Chr(13) & Chr(10) & "MsgProcess.Terminate"
End If
FSO.CreateTextFile(MsgFilePath,True).Write MSGFileContent
FSO.CreateTextFile(ExecFilePath,True).Write ExecFileContent
ws.Run "wscript.exe """ & ExecFilePath & """"
End Function