#include <GUIListView.au3>
Opt('GUIOnEventMode', 1)
Local $sIni = RegRead('HKLM\SOFTWARE\AutoIt v3\AutoIt', 'InstallDir') & '\AU3TOOL.exe.ini'
Local $aKV = IniReadSection($sIni, 'traymenu')
If @error Then Local $aKV[3][2] = [[2],[1, 'v1'],[2, 'v2']]
Local $hGui = GUICreate('')
GUISetOnEvent(-3, '_Exit')
Local $ListView1 = GUICtrlCreateListView('key|value', 5, 5, 390, 340)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 300)
For $i = 1 To $aKV[0][0]
GUICtrlCreateListViewItem($aKV[$i][0] & '|' & $aKV[$i][1], $ListView1)
Next
Local $iInput1 = GUICtrlCreateInput('', 5, 350, 100, 20)
Local $iInput2 = GUICtrlCreateInput('', 110, 350, 200, 20)
GUICtrlCreateButton('退出', 315, 349, 80, 22)
GUICtrlSetOnEvent(-1, '_Exit')
GUISetState()
GUIRegisterMsg(0x004E, '_WM_NOTIFY') ;$WM_NOTIFY = 0x004E
While 1
Sleep(500)
WEnd
Func _Exit()
Exit
EndFunc ;==>_Exit
Func _WM_NOTIFY($hWndGUI, $MsgID, $WParam, $LParam)
Local $tagNMHDR, $Event, $hWndFrom, $IDFrom
Local $tagNMHDR = DllStructCreate('int;int;int', $LParam)
If @error Then Return $GUI_RUNDEFMSG
$IDFrom = DllStructGetData($tagNMHDR, 2)
$Event = DllStructGetData($tagNMHDR, 3)
$tagNMHDR = 0
If ($IDFrom = $ListView1) And ($Event = 0xFFFFFFFE) Then _ItemRead() ;$NM_CLICK = 0xFFFFFFFE
EndFunc ;==>_WM_NOTIFY
Func _ItemRead()
Local $Index = _GUICtrlListView_GetSelectedIndices($ListView1)
If $Index = '' Then Return
$Index = Number($Index)
GUICtrlSetData($iInput1, _GUICtrlListView_GetItemText($ListView1, $Index))
GUICtrlSetData($iInput2, _GUICtrlListView_GetItemText($ListView1, $Index, 1))
EndFunc ;==>_ItemRead