1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| Option Explicit
Const AppTitle = "PDFCreator - MSAgent"
Const TextToSpeech = "Le fichier pdf à été créé ! Pensez à supprimer le fichier original"
Const AgentName = "Merlin"
Dim objAgent, objCharacter, c, HideID, LastID
LastID = 0
On Error Resume Next
Set objAgent = CreateObject("Agent.Control.2")
If Err.Number <> 0 Then
MsgBox "This script needs MS SAPI runtime." & vbcrlf & vbcrlf & _
"For more informations use this link." & vbcrlf & _
"http://www.microsoft.com/MSAGENT/downloads/user.asp#sapi" & vbcrlf & vbcrlf & _
Err.Number & " " & Err.Description, vbCritical, AppTitle
WScript.Quit
End If
WScript.ConnectObject objAgent, "Agent_"
objAgent.Connected = TRUE
objAgent.Characters.Load AgentName, AgentName & ".acs"
If Err.Number <> 0 Then
MsgBox "Try to load the agent character file: " & AgentName & ".acs" & vbcrlf & vbcrlf & _
"For more informations use this link." & vbcrlf & _
"http://www.microsoft.com/MSAGENT/downloads/user.asp#character" & vbcrlf & vbcrlf & _
Err.Number & " " & Err.Description, vbCritical, AppTitle
WScript.Quit
End If
Set objCharacter = objAgent.Characters.Character(AgentName)
With objCharacter
.Show
.LanguageID = &H0409 ' English
.Play "GetAttention"
.Speak TextToSpeech
Set HideID = .Hide
End With
c = 150 ' Don't wait more than 15 seconds
Do While (c > 0) and (LastID <> HideID)
c = c -1
Wscript.Sleep 100
Loop
Public Sub Agent_RequestComplete(ByVal Request)
LastID = Request
If MsgBox("Voulez vous supprimer le fichier source ?",vbQuestion + vbYesNo + vbSystemModal + 0,"Suppression du fichier source") = vbYes Then
'déclaration file system object
Dim fso
'instanciation
Set FSO = CreateObject("Scripting.FileSystemObject")
'Suppression du fichier
Set Ftxt = fso.GetFile("C:\Documents and Settings\stagiaire1\Bureau\Nouveau_Document_texte.txt") 'Fichier origine
Ftxt.delete
Else Wscript.Quit
End if
End Sub |
Partager