闲来无事,突发奇想,写了下面一段脚本,功能是自动朗读碧聊聊天室个人包厢的信息。
函数过滤掉了消息时间。
调用了sapi5的com接口,您需要首先在控制面板的“语音”中设置好默认的中文语音。有兴趣的朋友可以尝试写出gui便可以加上选择语音功能。
另在某些情况下突然关闭浏览器窗口会导致脚本出错,可能是ieudf函数的问题。

#include
opt("WinTitleMatchMode",2)
$objvoice = objcreate("sapi.spvoice")
$objvoice.volume =50
;$objvoice.rate = 9
$ocon =""

$objvoice.speak("晴天聊天小助手",1)
while 1
if WinExists(".bliao.com") =1 then
bliao()
endif
sleep(500)
wend


func bliao()
$oie = _IEAttach(".bliao.com")
$oid = _IEFrameGetObjByName($oie,"u1")
$ostr = _IEBodyReadText($oid)
if StringLen($ostr)> $ocon then
$astr = StringTrimLeft($ostr,$ocon)
$str = StringRegExpReplace($astr,"\(\d{2}:\d{2}:\d{2}\)","")
$objvoice.speak($str)
$ocon = StringLen($ostr)
$oie ="null"
endif
if StringLen($ostr)< $ocon AND $ostr<>"" then
$str = StringRegExpReplace($ostr,"\(\d{2}:\d{2}:\d{2}\)","")
;if NOT $str = $oldstr then
$objvoice.speak($str,1)
$ocon = StringLen($ostr)
;$oldstr = $str
$oie ="null"
endif
endfunc

标签:脚本, au3

你的评论