#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListView.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
;
; AutoIt Version: 3.0
; Language: 中文
; Platform: XP
; Author: Taxan
; Q ·1·Q:8·5196830·
; Description: 自己做的一个RTX腾讯通自动回复功能,做的很糙,但是满足自己的要求了。希望对你们有用!
; 其中“#32770”是用Window Info获取的我的腾讯通窗口类名
; "RichEdit20W2"是聊天对话框中的聊天记录的控件ID
; "RichEdit20W1"是聊天对话框中的聊天编辑区域的控件ID
Opt("GUIOnEventMode", 1) ; 切换为 OnEvent 模式
Dim $co
$co = 0
Dim $ListView[20]
Dim $OnOff
$Onoff = 0
#Region ### START Koda GUI section ### Form=d:\koda\forms\rtx消息自动回复.kxf
$MainForm = GUICreate("RTX消息机器人", 572, 308, 237, 199)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") ; 设置窗口关闭事件
$Group1 = GUICtrlCreateGroup("添加监控内容", 16, 16, 225, 193)
$Label1 = GUICtrlCreateLabel("发送人:", 40, 42, 52, 17)
$Label2 = GUICtrlCreateLabel("关键字:", 40, 81, 52, 17)
$Label3 = GUICtrlCreateLabel("回 复:", 40, 120, 52, 17)
$Sender = GUICtrlCreateInput("Sender", 96, 40, 121, 21)
$KeyWord = GUICtrlCreateInput("KeyWord", 96, 79, 121, 21)
$Received = GUICtrlCreateInput("Received", 96, 118, 121, 21)
$MonitorAdd = GUICtrlCreateButton("添加", 52, 160, 51, 25)
GUICtrlSetOnEvent($MonitorAdd, "OnMonitorAdd") ; 设置添加事件
$MonitorDel = GUICtrlCreateButton("删除", 168, 160, 51, 25)
GUICtrlSetOnEvent($MonitorDel, "OnMonitorDel") ; 设置删除事件
GUICtrlCreateGroup("", -99, -99, 1, 1)
$ListView1 = GUICtrlCreateListView("发送人|关键字|回复", 248, 24, 306, 182)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 100)
_GUICtrlListView_JustifyColumn(GUICtrlGetHandle($ListView1), 1, 2)
_GUICtrlListView_JustifyColumn(GUICtrlGetHandle($ListView1), 2, 2)
$ListView1_1= GUICtrlCreateListViewItem("管理|通知|收到", $ListView1)
$ListView1_2 = GUICtrlCreateListViewItem("葫芦岛|通知|收到", $ListView1)
$Start = GUICtrlCreateButton("监听", 184, 240, 75, 25)
GUICtrlSetOnEvent($Start, "OnStart") ; 设置开始事件
$Stop = GUICtrlCreateButton("停止", 296, 240, 75, 25)
GUICtrlSetOnEvent($Stop, "OnStop") ; 设置停止事件
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
Sleep(5000)
If $Onoff = 1 Then
MonitorStart()
EndIf
WEnd
Func CLOSEClicked()
Exit
EndFunc
Func OnMonitorAdd ()
$ListView[$co] = GUICtrlCreateListViewItem(GUICtrlRead($Sender) & "|" & GUICtrlRead($KeyWord) & "|" & GUICtrlRead($Received), $ListView1)
$co = $co + 1
EndFunc
Func OnMonitorDel()
If GUICtrlDelete(GUICtrlRead ($ListView1 )) = 1 Then
$co = $co - 1
EndIf
EndFunc
Func OnStart()
$Onoff = 1
EndFunc
Func OnStop()
$Onoff = 0
EndFunc
Func MonitorStart()
Send("^!x")
$Compare = GetSender($ListView1_1)
If $Compare[0] = 4 Then
;监控内容
MonitorExe($Compare) ;执行监控
EndIf
$Compare = GetSender($ListView1_2)
If $Compare[0] = 4 Then
;监控内容
MonitorExe($Compare) ;执行监控
EndIf
For $i = 0 to 19
$Compare = GetSender($ListView[$i])
If $Compare[0] = 4 Then
;监控内容
MonitorExe($Compare) ;执行监控
EndIf
Next
EndFunc
Func GetSender($a) ;获取ListViewItem的发送者 $a为ListViewItem的ID
;$str[1]为Sender
;$str[2]为KeyWord
;$str[3]为Received
Local $str
$str = GUICtrlRead($a)
;$str = StringSplit(StringReplace($str, "\n","|"),"|")
$str = StringSplit($str,"|")
Return $str
EndFunc
Func MonitorExe($b) ;执行监控
$win_list = WinList("[REGEXPCLASS:#32770]")
If $win_list[0][0] <> 0 Then
for $i = 1 to $win_list[0][0]
If StringRight ( $win_list[$i][0], 6) ="RTX 会话" Then
$title = _WinAPI_GetWindowText($win_list[$i][1])
WinActivate($title, "")
$text = ControlGetText ($title, "", "RichEdit20W2") ;RichEdit20W2 聊天记录框的控件名,$text为消息内容
If @error <> 1 Then
;这里填加比较,是否有Sender发送KeyWord消息,为了避免漏接收,这里只要含有Sender和KeyWord通认为是有消息
;
If StringInStr($text,$b[1]) > 0 Then
$text_delSpace = StringStripWS($text,8)
If StringInStr($text_delSpace,$b[2]) > 0 Then
ControlSend ( $title , "" , "RichEdit20W1",$b[3] & "!S" & "!C")
EndIf
EndIf
EndIf
EndIf
Next
EndIf
EndFunc