#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ListviewConstants.au3>
#include <GuiListView.au3>
Dim $result[10]
$Form1 = GUICreate("test", 240, 125, 192, 124)
$ListView1 = GUICtrlCreateListView(" ", 0, 0, 240, 80)
GUICtrlSetStyle(-1, $LVS_ICON)
$Button1 = GUICtrlCreateButton("生成", 22, 85, 81, 33)
$Button2 = GUICtrlCreateButton("选择", 132, 85, 81, 33)
Read()
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
Read()
Case $Button2
$j = 0
$out = ""
For $i = 1 To 3
If $result[$i] And $result[$i + 4] And $result[$i + 5] And $result[$i + 6] Then
Selected($i, $i + 4, $i + 5, $i + 6)
$j+=1
Sleep (1000)
EndIf
ControlListView ( "", "", "SysListView321","DeSelect", 0,9)
If $result[$i] And $result[$i - 1] And $result[$i + 1] And $result[$i + 5] Then
Selected($i, $i - 1, $i + 1, $i + 5)
$j+=1
Sleep (1000)
EndIf
ControlListView ( "", "", "SysListView321","DeSelect", 0,9)
$temp = $result[$i] + $result[$i + 4] + $result[$i + 5] + $result[$i + 6]
If $temp >2 Then
If $result[$i+5] Then $out &= $i + 6 & @CRLF
EndIf
$temp = $result[$i] + $result[$i - 1] + $result[$i + 1] + $result[$i + 5]
If $temp >2 Then
If $result[$i] Then $out &= $i+1 &@CRLF
EndIf
Next
If $j Then
MsgBox (0,"","共有"&$j&"组匹配T型")
Else
If $out <> "" Then
MsgBox (0,"","最大匹配的数是:"&@CRLF&$out)
Else
MsgBox (0,"","没有匹配多于2个的数")
EndIf
EndIf
EndSwitch
WEnd
Func Read()
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1))
For $i = 1 To 10
If Random(1, 99) < 80 Then
GUICtrlCreateListViewItem($i, $ListView1)
$result[$i - 1] = 1
Else
GUICtrlCreateListViewItem("", $ListView1)
$result[$i - 1] = 0
EndIf
Next
EndFunc ;==>Read
Func Selected($a='', $b='', $c='', $d='')
ControlListView("", "", "SysListView321", "Select", $a)
ControlListView("", "", "SysListView321", "Select", $b)
ControlListView("", "", "SysListView321", "Select", $c)
ControlListView("", "", "SysListView321", "Select", $d)
ControlFocus("", "", "SysListView321")
EndFunc ;==>Selected