#cs ======================================================================================== Scripted in ....: AutoIt v3.3.14.5 (Released on 3.16.2018) Scripted on ....: Windows 10 Home Version: 1803 (10.0.17134.885) Date Started ...: [07.10.2019] Last Updated ...: [07.17.2019] Script Function... Build to test the detection of a single and double click within a Gui list (Not a ListView) using $WM_COMMAND... Windows Message Code: 273 Update: Now includes 2 buttons and $WM_COMMAND [Enter] key detection. #ce ======================================================================================== #include ;-------------------------- Global $Element001 = 0 Global $Element002 = 0 Global $Element003 = 0 Global $FocusFound = 0 ;-------------------------- Global $GetMessage = 0 Global $ParentWind = 0 Global $MouseClick = False Global $EnterPress = False ;-------------------------- $WindHandle = GUICreate("Left Mouse Click / Enter Key Demo", 400, 420) $ParentWind = $WindHandle ;---------------------------------->> Hold WinHandle of Parent Win $ViewCtID01 = GuiCtrlCreateList("Left-Double-Click or press [Enter]" , 100, 20, 200, 150) $ViewCtWH01 = GUICtrlGetHandle($ViewCtID01) ;---------------->> Get: WinHandle of Control ID $ViewCtID02 = GuiCtrlCreateList("Left-Single-Click or press [Enter]" , 100, 200, 200, 150) $ViewCtWH02 = GUICtrlGetHandle($ViewCtID02) ;---------------->> Get: WinHandle of Control ID $ButtonID01 = GUICtrlCreateButton("- Close Window -", 50, 370, 120, 30) $ButtonID02 = GUICtrlCreateButton("- Tester Button -", 220, 370, 120, 30) GUIRegisterMsg($WM_COMMAND, "_WinCommand01") GUISetState(@SW_SHOW) ;-------------------------------------------------------------------------------------------------------------- While 1 $GetMessage = 0 $GetMessage = GUIGetMsg() If $GetMessage = $GUI_EVENT_CLOSE Then Exit If $GetMessage = $ButtonID01 Then Exit If $GetMessage = $ButtonID02 Then MsgBox(64, "Event Detected", "Tester Button was pressed!", 90, $ParentWind) EndIf If $MouseClick = True Then $MouseClick = False ;-------------------------------->> Reset: MouseLeftClickFlag=False If $Element002 = 3 Then ;---------------------------->> $IDFrom=3 | $Code=2 (Left-Double-Click) MsgBox(64, "Elements", "Elements [1-3] = ["&$Element001&"] ["&$Element002&"] ["&$Element003&"]", 90, $ParentWind) MsgBox(64, "Event Detected", "Double-Click Detected in TOP (Num: 3) List!", 90, $ParentWind) EndIf If $Element002 = 4 Then ;---------------------------->> $IDFrom=4 | $Code=1 (Left-Single-Click) MsgBox(64, "Elements", "Elements [1-3] = ["&$Element001&"] ["&$Element002&"] ["&$Element003&"]", 90, $ParentWind) MsgBox(64, "Event Detected", "SINGLE Click Detected in BOTTOM (Num: 4) List!", 90, $ParentWind) EndIf EndIf ;---------------------------------------------------------------------------------------------------------- If $EnterPress = True Then $EnterPress = False ;-------------------------------->> Reset: [Enter]PressedFlag=False If $Element002 = 1 Then ;---------------------------->> $IDFrom=1 | $Code=0 (Enter-Key-Pressed) $FocusFound = ControlGetFocus($ParentWind) If $FocusFound = "ListBox1" Then ;-------------->> If -TOP!- ListBox has the Focus Then... MsgBox(64, "Elements", "Elements [1-3] = ["&$Element001&"] ["&$Element002&"] ["&$Element003&"]", 90, $ParentWind) MsgBox(64, "Event Detected", "Enter Pressed Detected in TOP List!", 90, $ParentWind) EndIf If $FocusFound = "ListBox2" Then ;-------------->> If BOTTOM ListBox has the Focus Then... MsgBox(64, "Elements", "Elements [1-3] = ["&$Element001&"] ["&$Element002&"] ["&$Element003&"]", 90, $ParentWind) MsgBox(64, "Event Detected", "Enter Pressed Detected in BOTTOM List!", 90, $ParentWind) EndIf EndIf EndIf WEnd Exit ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Func _WinCommand01($hWndFrom, $iMsg, $wParam, $lParam) ;------------------------------------------------- Local $IDFrom = BitAND($wParam, 0xFFFF) ; Low Word ;----->> IDFrom = Control's ID Number Local $Code = BitShift($wParam, 16) ; Hi Word! ;----->> Code = Window MsgCode Number $Element001 = $hWndFrom $Element002 = $IDFrom $Element003 = $Code ;------------------------ If $Element002 = 1 Then If $Element003 = 0 Then ;---------------------------->> $IDFrom=1|$Code=0 [EnterKey-Pressed!] $EnterPress = True EndIf EndIf If $Element002 = 3 Then If $Element003 = 2 Then ;---------------------------->> $IDFrom=3|$Code=2 [Left-Double-Click] $MouseClick = True EndIf EndIf If $Element002 = 4 Then If $Element003 = 1 Then ;---------------------------->> $IDFrom=4|$Code=1 [Left-Single-Click] $MouseClick = True EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_WinCommand01 ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++