#include <Date.au3>
HotKeySet('{esc}', '_Exit')
Local $o_speech, $Flag = 0, $hWnd, $sTitle, $sTxt, $sLast, $sAll
AdlibRegister('_GetWinTxt')
While 1
If $Flag Then
If $sAll <> $sLast Then
FileWrite(@ScriptDir & '\my.txt', '[' & _NowTime() & ']' & @CRLF & $sAll & @CRLF & @CRLF)
$sLast = $sAll
EndIf
$o_speech = ObjCreate('SAPI.SpVoice')
$o_speech.Speak($sTitle & @CRLF & $sAll, 1)
Else
Sleep(1)
EndIf
WEnd
Func _GetWinTxt()
$hWnd = WinGetHandle('[CLASS:#32770]', '设置关注')
If Not $hWnd Then
$Flag = 0
Return 0
EndIf
$sTitle = _GetWinTextFromPoint('[CLASS:#32770]', '设置关注', 13, 7)
$sTxt = _GetWinTextFromPoint('[CLASS:#32770]', '设置关注', 13, 51)
$sAll = $sTitle & @CRLF & $sTxt
If $sAll == $sLast Then
$Flag = 0
Return 0
EndIf
$Flag = 1
EndFunc ;==>_GetWinTxt
Func _Exit()
Exit
EndFunc ;==>_Exit
Func _GetWinTextFromPoint($title, $text, $_x, $_y)
;afan提示:获取窗口指定坐标点包含的窗口(控件)的文本
Local $hWnd = WinGetHandle($title, $text)
Local $tPoint = DllStructCreate('long X;long Y')
DllStructSetData($tPoint, 1, $_x)
DllStructSetData($tPoint, 2, $_y)
DllCall('user32.dll', 'bool', 'ClientToScreen', 'hwnd', $hWnd, 'ptr', DllStructGetPtr($tPoint))
Local $tPointCast = DllStructCreate('int64', DllStructGetPtr($tPoint))
Local $aRt0 = DllCall('user32.dll', 'hwnd', 'WindowFromPoint', 'int64', DllStructGetData($tPointCast, 1))
If @error Then Return SetError(2, '', '')
Return ControlGetText($hWnd, '', $aRt0[0])
EndFunc ;==>_GetWinTextFromPoint
更完善点的函数 _GetWinInfoFromPoint 在此