#include <WinAPI.au3>
#include <Date.au3>
#include <Array.au3>
HotKeySet('{esc}', '_Exit')
Local $o_speech, $Flag = 0, $hWnd, $sAllstring, $sTitle, $sLast, $sAll
Local $zb1, $zb2
Local $GetStatic1x,$GetStatic2x,$GetStatic3x
Local $GetStaticTitile,$GetStaticName ,$GetStaticTxt
;$GetStaticTitile = ControlGetText($hWnd, '', $GetStatic1x);获取标题栏
;GetStaticX()
AdlibRegister('_GetWinTxt',2000)
;分别获取指定控件的id
;GetStaticX()
;Local $zb1, $zb2
;Local $GetStatic1x,$GetStatic2x,$GetStatic3x
Func GetStaticX()
Local $GetStaticjs,$js
For $GetStaticjs=1 To 3 Step 1
;Local $js
$js=$js+1
Switch $js
Case 1
;标题
$zb1=13
$zb2=7
_get_ctr_id_by_zb($zb1, $zb2,$hWnd);调用子程序
ControlFocus($hWnd,"",_get_ctr_id_by_zb($zb1, $zb2,$hWnd));设置指定控件为当前焦点
$GetStatic1x=ControlGetFocus($hWnd)
Sleep(100)
Case 2
;网名
$zb1=13
$zb2=31
_get_ctr_id_by_zb($zb1, $zb2,$hWnd);调用子程序
ControlFocus($hWnd,"",_get_ctr_id_by_zb($zb1, $zb2,$hWnd));设置指定控件为当前焦点
$GetStatic2x=ControlGetFocus($hWnd)
Sleep(100)
Case 3
;内容
$zb1=13
$zb2=51
_get_ctr_id_by_zb($zb1, $zb2,$hWnd);调用子程序
ControlFocus($hWnd,"",_get_ctr_id_by_zb($zb1, $zb2,$hWnd));设置指定控件为当前焦点
$GetStatic3x=ControlGetFocus($hWnd)
Sleep(100)
EndSwitch
;MsgBox(262149,"测试FOR次数GetStaticX() :"&$js&" zb1:"&$zb1&" zb2:"&$zb2,"标题:" & $GetStatic1x & " 网名:" & $GetStatic2x & " 文本:" & $GetStatic3x & @CRLF ,2)
Next
;MsgBox(262149,"测试FOR次数Next :"&$js&" zb1:"&$zb1&" zb2:"&$zb2,"标题:" & $GetStatic1x & " 网名:" & $GetStatic2x & " 文本:" & $GetStatic3x & @CRLF ,2)
;$GetStaticTitile=ControlGetText($hWnd, '', $GetStatic1x);获取标题
;$GetStaticName=ControlGetText($hWnd, '', $GetStatic2x);获取网名
;$GetStaticTxt=ControlGetText($hWnd, '', $GetStatic3x);获取文本
;MsgBox(262149,"测 试Next" & "zb1:"&$zb1&" zb2:"&$zb2,"标题:" & $GetStaticTitile & @CRLF & " 网名:" & $GetStaticName & @CRLF & " 文本:" & $GetStaticTxt & @CRLF )
EndFunc
;根据指定坐标获取该控件句柄
Func _get_ctr_id_by_zb($zb1, $zb2,$hWnd )
Local $tPoint = DllStructCreate($tagPoint);创建一个 C/C++ 样式的数据结构供 DllCall 使用
DllStructSetData($tPoint, 1, $zb1) ;设置数据结构(struct)中部分元素的数据.
DllStructSetData($tPoint, 2, $zb2)
_WinAPI_ClientToScreen(WinGetHandle($hWnd ), $tpoint);转换客户区窗口指定点的坐标到一个屏幕坐标
$hStatic = _WinAPI_WindowFromPoint($tPoint);检索包含指定点的窗口句柄
;Local $controlid
;$controlid = _WinAPI_GetDlgCtrlID($hWnd);检索指定控件的标识符
;Return $controlid
Return $hStatic ;返回控任句柄
EndFunc
;主程序
;Local $GetStaticTitile,$GetStaticName ,$GetStaticTxt
Func _GetWinTxt()
;$hWnd = WinGetHandle('[CLASS:#32770]', '设置关注')
$hWnd = WinGetHandle("[CLASS:#32770]","设置关注")
;MsgBox(262149,"测 试",$hWnd ,2);测试专用
GetStaticX()
;MsgBox(262149,"测 试_GetWinTxt" & "zb1:"&$zb1&" zb2:"&$zb2,"标题:" & $GetStaticTitile & @CRLF & " 网名:" & $GetStaticName & @CRLF & " 文本:" & $GetStaticTxt & @CRLF )
If Not $hWnd Then
$Flag = 0
Return 0
EndIf
$GetStaticTitile = ControlGetText($hWnd, '', $GetStatic1x);获取标题栏
;MsgBox(262149,"测 试",$sWin ,2);测试专用
If StringInStr($GetStaticTitile,"灌水帖")>0 Then
$sTitle="灌水帖"
EndIf
If StringInStr($GetStaticTitile ,"竞猜")>0 Then
$sTitle="竞猜"
EndIf
If StringInStr($GetStaticTitile ,"实时看盘")>0 Then
$sTitle="实时看盘"
EndIf
$GetStaticName = ControlGetText($hWnd, "", $GetStatic2x)
$GetStaticTxt = ControlGetText($hWnd, "", $GetStatic3x)
;MsgBox(262149,"测 试",$sTitle & @CRLF & $sName & @CRLF & $sTxt ,2);测试专用
$sAll = $sTitle & $GetStaticName & $GetStaticTxt
If $sAll == $sLast Then
$Flag = 0
Return 0
EndIf
$Flag = 1
EndFunc ;==>_GetWinTxt
Func _Exit()
Exit
EndFunc ;==>_Exit
;始终检测主程序
While 1
If $Flag Then
If $sAll <> $sLast Then
FileWrite(@ScriptDir & '\理想通伴侣.txt','[' &_NowDate() & " " & _NowTime() & ']' & @CRLF & "[" & $sTitle & "]" & $GetStaticName& ": “" & $GetStaticTxt & "”" & @CRLF & @CRLF)
$sLast = $sAll
EndIf
$o_speech = ObjCreate('SAPI.SpVoice')
;$o_speech.Speak($sTitle & @CRLF & $sAll, 1)
$o_speech.Speak( $sAll, 1)
Else
Sleep(1)
EndIf
WEnd