JohnRichard Posted April 23, 2009 Share Posted April 23, 2009 Hi all. I wanted to select item in listviewitem. what i have currently is to click item in listview then perform action when i click on selected item. What i wanted is to double click it instead of single click the item. i am using the $GUI_EVENT_PRIMARYDOWN to perform the action. Is there any way to double click the item then it will perform the desired function? here is the sample code. appreciate any suggestions and ideas. thanks. #include <GuiConstants.au3> #include <GuiListView.au3> Opt('MustDeclareVars', 1) Dim $listview, $Btn_Get, $Btn_GetSelected, $Btn_Exit, $msg, $Status, $a_Item, $i, $input GUICreate("ListView Get Item Text Array", 392, 322) $listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149) GUICtrlCreateListViewItem("line1|data1|more1", $listview) GUICtrlCreateListViewItem("line2|data2|more2", $listview) GUICtrlCreateListViewItem("line3|data3|more3", $listview) GUICtrlCreateListViewItem("line4|data4|more4", $listview) GUICtrlCreateListViewItem("line5|data5|more5", $listview) $Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30) $Status = GUICtrlCreateInput("", 50, 200, 40, 20) $input = GUICtrlCreateInput("", 50, 230, 40, 20) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit ExitLoop Case $msg = $GUI_EVENT_PRIMARYDOWN $a_Item = _GUICtrlListView_GetItemTextArray($listview) If IsArray($a_Item) Then MsgBox(0, "", $a_Item) GUICtrlSetData($Status, "") GUICtrlSetData($Status, $a_Item[1]) GUICtrlSetData($input, $a_Item[2]) Else GUICtrlSetData($input, "") EndIf EndSelect WEnd Exit Link to comment Share on other sites More sharing options...
Marlo Posted April 23, 2009 Share Posted April 23, 2009 (edited) I use the following method: GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam) Local $tagNMHDR, $event, $hwndFrom, $code $tagNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return 0 $code = DllStructGetData($tagNMHDR, 3) If $wParam = $ListView And $code = -3 And _GUICtrlListView_GetSelectedCount($ListView) > 0 Then ;Put code here to deal with the double click Return $GUI_RUNDEFMSG EndFunc Edited April 23, 2009 by Marlo Click here for the best AutoIt help possible.Currently Working on: Autoit RAT Link to comment Share on other sites More sharing options...
JohnRichard Posted April 23, 2009 Author Share Posted April 23, 2009 I use the following method: GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam) Local $tagNMHDR, $event, $hwndFrom, $code $tagNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return 0 $code = DllStructGetData($tagNMHDR, 3) If $wParam = $ListView And $code = -3 And _GUICtrlListView_GetSelectedCount($ListView) > 0 Then ;Put code here to deal with the double click Return $GUI_RUNDEFMSG EndFunc thanks Marlo. I'll try this. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 23, 2009 Moderators Share Posted April 23, 2009 JohnRichard,I use a slightly different method. I set a flag when the double click is detected and then run code from within the While...WEnd loop. That way you return from the GUIRegisterMsg function ASAP - as recommended by the Help file: "the return to the system should be as fast as possible !!!".So it looks something like this when put into a script:; Register "Click on ListView function" GUIRegisterMsg($WM_NOTIFY, "MY_WM_NOTIFY") While 1 ; Normal GUIGetMsg() code ; Check if mouse has doubleclicked If $fDblClk = True Then $fDblClk = False ExitLoop ; You could also put the doubleclicked list code here if you prefer EndIf Wend ; Deregister "Click on ListView function" GUIRegisterMsg($WM_NOTIFY, "") ; Code for doubleclicked list follows here ; ----------- Func MY_WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return If DllStructGetData($tNMHDR, 3) = $NM_DBLCLK Then $fDblClk = True $tNMHDR = 0 EndFuncI have found this to work well in a number of scripts.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now