Jump to content
Sign in to follow this  
sigil

how to detect double-click on a list item?

Recommended Posts

sigil

I want to make a list, and let the user select an item from the list by double-clicking it. I've read the help file, and it seems like I need to use $LBS_NOTIFY when I declare my list, but I don't know how to detect the double-click, so that I can make the list window close once the user has selected the item. So far, I can detect a single-clicked value, but I want to make it more user-friendly by only executing the next code section if there's a double-click.

Here's my code:

#include <guiconstants.au3>

$null=""
dim $choices[4]=[1,2,3,4]

guicreate("My List")
$options=guictrlcreatelist($null,10,20,200,200,$lbs_notify)
for $c=0 to ubound($choices)-1
    $text=$choices[$c]
    guictrlsetdata($options,$text)
Next
guisetstate()
while 1
    $msg=guigetmsg()
    $selection=guictrlread($options)
    if ($msg=$gui_event_close) or ($msg=$options) Then
        ExitLoop
    EndIf
WEnd
msgbox(0,"",$selection)

Share this post


Link to post
Share on other sites
MrCreatoR

Hi,

I don't sure about List, but maybe ListView?

#include <GuiConstants.au3>

Global Const $WM_NOTIFY = 0x004E
Global $DoubleClicked   = False

GUICreate("Double Click Demo", 400, 300)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")


$ListViewID = GuiCtrlCreateListView("List Column", 10, 20, 380, 250)

For $i = 1 To 10
    GuiCtrlCreateListViewItem("Item " & $i, $ListViewID)
Next

GUISetState()

While GUIGetMsg() <> -3
    Sleep(10)
    If $DoubleClicked Then
        DoubleClickFunc()
        $DoubleClicked = False
    EndIf
WEnd

Func DoubleClickFunc()
    MsgBox(64, "OK", "Double Clicked: " & GUICtrlRead(GUICtrlRead($ListViewID)))
EndFunc

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 = $ListViewID And $code = -3 Then $DoubleClicked = True
    Return $GUI_RUNDEFMSG
EndFunc

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites
GaryFrost

Global Const $WM_COMMAND                        = 0x0111

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")oÝ÷ Ù«­¢+ÙÕ¹]5}
=559 ÀÌØí¡]¹°ÀÌØí¥5Í°ÀÌØí¥ÝAÉ´°ÀÌØí¥±AÉ´¤(%1½°ÀÌØí¡]¹É½´°ÀÌØí¥%ɽ´°ÀÌØí¥
½°ÀÌØí¡]¹1¥ÍÑ    ½à(%%9½Ð%Í!]¹ ÀÌØí¡1¥ÍÑ   ½à¤Q¡¸ÀÌØí¡]¹1¥ÍÑ ½àôU%
ÑɱÑ!¹± ÀÌØí¡1¥ÍÑ ½à¤($ÀÌØí¡]¹É½´ôÀÌØí¥±AÉ´($ÀÌØí¥%ɽ´ô ¥Ñ9 ÀÌØí¥ÝAÉ´°Áá¤ì1½Ü]½É($ÀÌØí¥
½ô    ¥ÑM¡¥Ð ÀÌØí¥ÝAÉ´°Äؤì!¤]½É((%MÝ¥Ñ ÀÌØí¡]¹É½´($%
ÍÀÌØí¡1¥ÍÑ ½à°ÀÌØí¡]¹1¥ÍÑ  ½à($$%MÝ¥Ñ ÀÌØí¥
½($$$%
ÍÀÌØí1 9}  1
1,ìM¹ÐÝ¡¸Ñ¡ÕÍȽձµ±¥­ÌÍÑÉ¥¹¥¸±¥Íнà($$$$%}ÕAÉ¥¹Ð ÅÕ½ÐìÀÌØí1   9}  1
1,ÅÕ½ÐìµÀì1µÀìÅÕ½Ðì´´ØÈì¡]¹É½´èÅÕ½ÐìµÀìQµÀìÀÌØí¡]¹É½´µÀì1µÀì|($$$$$$$ÅÕ½Ðì´´ØÈí%ɽ´èÅÕ½ÐìµÀìQµÀìÀÌØí¥%ɽ´µÀì1µÀì|($$$$$$$ÅÕ½Ðì´´ØÈí
½èÅÕ½ÐìµÀìQµÀìÀÌØí¥
½¤($$$$$ì¹¼ÉÑÕɸٱÕ($$$%
ÍÀÌØí1 9}IIMA
ìM¹ÐÝ¡¸±¥Íн๹½Ð±±½Ñ¹½Õ µµ½ÉäѼµÐÍÁ¥¥ÉÅÕÍÐ($$$$%}ÕAÉ¥¹Ð ÅÕ½ÐìÀÌØí1  9}IIMA
ÅÕ½ÐìµÀì1µÀìÅÕ½Ðì´´ØÈì¡]¹É½´èÅÕ½ÐìµÀìQµÀìÀÌØí¡]¹É½´µÀì1µÀì|($$$$$$$ÅÕ½Ðì´´ØÈí%ɽ´èÅÕ½ÐìµÀìQµÀìÀÌØí¥%ɽ´µÀì1µÀì|($$$$$$$ÅÕ½Ðì´´ØÈí
½èÅÕ½ÐìµÀìQµÀìÀÌØí¥
½¤($$$$$ì¹¼ÉÑÕɸٱÕ($$$%
ÍÀÌØí1 9}-%11=
ULìM¹ÐÝ¡¸±¥Íн౽ÍÌÑ¡­å½É½ÕÌ($$$$%}ÕAÉ¥¹Ð ÅÕ½ÐìÀÌØí1 9}-%11=
ULÅÕ½ÐìµÀì1µÀìÅÕ½Ðì´´ØÈì¡]¹É½´èÅÕ½ÐìµÀìQµÀìÀÌØí¡]¹É½´µÀì1µÀì|($$$$$$$ÅÕ½Ðì´´ØÈí%ɽ´èÅÕ½ÐìµÀìQµÀìÀÌØí¥%ɽ´µÀì1µÀì|($$$$$$$ÅÕ½Ðì´´ØÈí
½èÅÕ½ÐìµÀìQµÀìÀÌØí¥
½¤($$$$$ì¹¼ÉÑÕɸٱÕ($$$%
ÍÀÌØí1 9}M1
9
0ìM¹ÐÝ¡¸Ñ¡ÕÍȹ±Ìѡͱѥ½¸¥¸±¥Íнà($$$$%}ÕAÉ¥¹Ð ÅÕ½ÐìÀÌØí1    9}M1
9
0ÅÕ½ÐìµÀì1µÀìÅÕ½Ðì´´ØÈì¡]¹É½´èÅÕ½ÐìµÀìQµÀìÀÌØí¡]¹É½´µÀì1µÀì|($$$$$$$ÅÕ½Ðì´´ØÈí%ɽ´èÅÕ½ÐìµÀìQµÀìÀÌØí¥%ɽ´µÀì1µÀì|($$$$$$$ÅÕ½Ðì´´ØÈí
½èÅÕ½ÐìµÀìQµÀìÀÌØí¥
½¤($$$$$ì¹¼ÉÑÕɸٱÕ($$$%
ÍÀÌØí1 9}M1
!9ìM¹ÐÝ¡¸Ñ¡Í±Ñ¥½¸¥¸±¥Íнà¡Ì¡¹($$$$%}ÕAÉ¥¹Ð ÅÕ½ÐìÀÌØí1   9}M1
!9ÅÕ½ÐìµÀì1µÀìÅÕ½Ðì´´ØÈì¡]¹É½´èÅÕ½ÐìµÀìQµÀìÀÌØí¡]¹É½´µÀì1µÀì|($$$$$$$ÅÕ½Ðì´´ØÈí%ɽ´èÅÕ½ÐìµÀìQµÀìÀÌØí¥%ɽ´µÀì1µÀì|($$$$$$$ÅÕ½Ðì´´ØÈí
½èÅÕ½ÐìµÀìQµÀìÀÌØí¥
½¤($$$$$ì¹¼ÉÑÕɸٱÕ($$$%
ÍÀÌØí1 9}MQ=
ULìM¹ÐÝ¡¸±¥ÍнàÉ¥ÙÌÑ¡­å½É½ÕÌ($$$$%}ÕAÉ¥¹Ð ÅÕ½ÐìÀÌØí1 9}MQ=
ULÅÕ½ÐìµÀì1µÀìÅÕ½Ðì´´ØÈì¡]¹É½´èÅÕ½ÐìµÀìQµÀìÀÌØí¡]¹É½´µÀì1µÀì|($$$$$$$ÅÕ½Ðì´´ØÈí%ɽ´èÅÕ½ÐìµÀìQµÀìÀÌØí¥%ɽ´µÀì1µÀì|($$$$$$$ÅÕ½Ðì´´ØÈí
½èÅÕ½ÐìµÀìQµÀìÀÌØí¥
½¤($$$$$ì¹¼ÉÑÕɸٱÕ($$%¹MÝ¥Ñ (%¹MÝ¥Ñ ($ìAɽѡձÐÕѽ¥ÐÌ¥¹Ñɹ°µÍͽµµ¹Ì¸($ìe½Ô±Í¼¸½µÁ±Ñ±ÐÑ¡±¥¹½Õи($ìÌÌìÌÌìÌÌì  Õн¹±äÌäíIÑÕɸÌäì¡Ý¥Ñ¡½Õйäٱդݥ±°¹½ÐÁɽ($ìÑ¡Õ±ÐÕѽ¥Ð̵µÍÍ¥¸Ñ¡ÕÑÕÉÌÌìÌÌìÌÌì(%IÑÕɸÀÌØíU%}IU95M)¹Õ¹ìôôÐí]5}
=559()Õ¹}ÕAÉ¥¹Ð ÀÌØíÍ}ÑáФ($ÀÌØíÍ}ÑáÐôMÑÉ¥¹IÁ± ÀÌØíÍ}Ñáа1°1µÀìÅÕ½Ðì´´ØÈìÅÕ½Ðì¤(%
½¹Í½±]É¥Ñ ÅÕ½ÐìÌÌìôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôÅÕ½ÐìµÀì1µÀì|($$$ÅÕ½Ðì¬ôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôÅÕ½ÐìµÀì1µÀì|($$$ÅÕ½Ðì´´ØÈìÅÕ½ÐìµÀìÀÌØíÍ}ÑáеÀì1µÀì|($$$ÅÕ½Ðì¬ôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôÅÕ½ÐìµÀì1¤)¹Õ¹ìôôÐí}ÕAÉ¥¹


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
GaryFrost

Where can you find the constants, such as $LBN_DBLCLK?

In the beta you should be able to find the constants depending which control etc your looking for.

For example $LBN_DBLCLK should be found in ListBoxConstants.au3

I'm guessing that is what you mean, if you mean where do the values come from I used a tool call APIViewer 2004


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
Achilles

In the beta you should be able to find the constants depending which control etc your looking for.

For example $LBN_DBLCLK should be found in ListBoxConstants.au3

I'm guessing that is what you mean, if you mean where do the values come from I used a tool call APIViewer 2004

Ok, thanks, I found them... however they were under #include <A3LListbox.au3> that PaulIA made and not in my beta. I'm downloading the newest beta now but it's going to take a few minutes.

EDIT: Beta fixed it. Now it the other constants I was using too :)

Edited by Piano_Man

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×