#Include <GUIConstantsEx.au3>
#Include <GUIListBox.au3>
#Include <WinAPI.au3>
#Include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
Global $hForm, $Msg, $Dummy, $List, $hList
$hForm = GUiCreate('MyGUI', 300, 400)
$List = GUICtrlCreateList('Item 1', 20, 20, 260, 360)
$hList = GUICtrlGetHandle(-1)
For $i = 2 To 9
GUICtrlSetData(-1, 'Item ' & $i)
Next
$Dummy = GUICtrlCreateDummy()
GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')
HotKeySet('{ENTER}', 'HKEnter')
GUISetState()
While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
ExitLoop
Case $Dummy
MsgBox(0, '', _GUICtrlListBox_GetText($hList, GUICtrlRead($Dummy)), 0, $hForm)
EndSwitch
WEnd
Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
Local $Index
Switch $lParam
Case $hList
Switch _WinAPI_HiWord($wParam)
Case $LBN_DBLCLK
$Index = _GUICtrlListBox_GetCurSel($hList)
If ($Index > -1) And (_GUICtrlListBox_GetCaretIndex($hList) = $Index) Then
GUICtrlSendToDummy($Dummy, $Index)
EndIf
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_COMMAND
Func HKEnter()
Local $Index
If _WinAPI_GetFocus() = $hList Then
$Index = _GUICtrlListBox_GetCurSel($hList)
If $Index > -1 Then
GUICtrlSendToDummy($Dummy, $Index)
Return
EndIf
EndIf
HotKeySet('{ENTER}')
Send('{ENTER}')
HotKeySet('{ENTER}', 'HKEnter')
EndFunc ;==>HKEdit