El siguiente código que les dejo es para un Macro de fecha y hora para nuestro asistente virtual.
Con el podremos preguntarle a nuestro equipo la fecha y hora actual (la que se encuentre configurada en el PC).
Macro para fecha
<command> <listenFor>Christine que dia es hoy</listenFor> <sendKeys>{{CTRL}}{RWin}</sendKeys> <script language="VBScript"> <![CDATA[ On Error Resume Next dayDate = Day(Now) anio = Year(Date) dayNumberText = " " & dayDate whatToSay = "Estamos a " & WeekdayName(Weekday(Now)) & ", " & dayNumberText & " de " & MonthName(Month(Now)) & " del año " & anio & " " Application.SetTextFeedback(whatToSay) Application.Speak(whatToSay) ]]> </script> <sendKeys>{{CTRL}}{RWin}</sendKeys> </command>
Macro para hora
<command> <listenFor>Christine dime la hora</listenFor> <sendKeys>{{CTRL}}{RWin}</sendKeys> <script language="JScript"> <![CDATA[ var date = new Date(); var whatToSay = "son las "; var hours = date.getHours(); var AMorPM; if (date.getHours() >= 12){ if (date.getHours() < 20){ AMorPM = " de la tarde"; }else{ AMorPM = " de la noche"; } if (date.getHours() != 12){ hours -= 12 } }else{ AMorPM = " de la mañana"; } whatToSay += hours; if (date.getMinutes() == 0){ whatToSay += " en punto"; }else{ if (date.getMinutes() < 10){ whatToSay += " "; } whatToSay += " " + date.getMinutes(); } whatToSay += AMorPM; Application.SetTextFeedback(whatToSay); Application.Speak(whatToSay); ]]> </script> <sendKeys>{{CTRL}}{RWin}</sendKeys> </command>
Aquí un video con la demostración.
Comprar manual