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
|
Option Explicit
Function dictée(texte)
Dim sTxt, URLFR
'sTxt =""
URLFR = "http://translate.google.com/translate_tts?ie=UTF-8&tl=fr&q=" & texte
If OnLine("smtp.gmail.com") = True Then
Call Kill("wmplayer.exe")
Call WmPlaySound(URLFR)
Pause (10)
Call Kill("wmplayer.exe")
End If
End Function
'**********************************************************************************************
Function OnLine(strHost)
Dim objPing, z, objRetStatus, PingStatus
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_PingStatus where address = '" & strHost & "'")
z = 0
Do
z = z + 1
For Each objRetStatus In objPing
If IsNull(objRetStatus.StatusCode) Or objRetStatus.StatusCode <> 0 Then
PingStatus = False
Else
PingStatus = True
End If
Next
Call Pause(1)
If z = 4 Then Exit Do
Loop Until PingStatus = True
If PingStatus = True Then
OnLine = True
Else
OnLine = False
End If
End Function
'*********************************************************************************************
'Fonction pour ajouter les doubles quotes dans une variable
Function DblQuote(Str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
'**********************************************************************************************
Sub WmPlaySound(MySound)
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "wmplayer " & DblQuote(MySound) & "", 0, False
Set WshShell = Nothing
End Sub
'**********************************************************************************************
Sub Kill(Process)
Dim Ws, Command, Execution
Set Ws = CreateObject("WScript.Shell")
Command = "cmd /c Taskkill /F /IM ""&Process&"""
Execution = Ws.Run(Command, 0, True)
End Sub
'**********************************************************************************************
Sub Pause(NSeconds)
' Wscript.Sleep (NSeconds * 1000)
End Sub
'********************************************************************************************** |
Partager