Jump to content

List View Item action on double click


Recommended Posts

I have this script and I want to run CreateIM function just for double click on any list view item. In this moment run for one click.

#include <GUIListView.au3>

Global $OFFLINE_VIEW = True
Global $ITEM[30]

Global $MAIN = GUICreate("IM",250,500,-1,-1,0x16C80000,0x00000181)
Global $LIST_VIEW = GUICtrlCreateListView("Username",5,5,240,490,BitOR(0x0004,0x0010,0x00200000))
For $INDEX = 0 To 29
    $ITEM[$INDEX] = GUICtrlCreateListViewItem("User " & $INDEX,$LIST_VIEW)
Next
Sleep(1000)
GUISetState(@SW_SHOW,$MAIN)

While True
    $MSG = GUIGetMsg()
    Switch $MSG
        Case -3
            Exit
    EndSwitch
    For $INDEX = 0 To _GUICtrlListView_GetItemCount($LIST_VIEW)-1
        If $MSG = $ITEM[$INDEX] Then
            CreateIM(_GUICtrlListView_GetItemText($LIST_VIEW,_GUICtrlListView_GetHotItem($LIST_VIEW)))
        EndIf
    Next
    Sleep(10)
WEnd

Func CreateIM($NAME)
    $GUI = GUICreate($NAME,200,200)
    GUISetState(@SW_SHOW,$GUI)
    While True
        $GUI_MSG = GUIGetMsg()
        If $GUI_MSG = -3 Then
            GUIDelete($GUI)
            ExitLoop
        EndIf
        Sleep(10)
    WEnd
EndFunc

When the words fail... music speaks.

Link to comment
Share on other sites

I use GUIRegisterMsg to catch the user actions. The example for _GUICtrlListView_Create shows how to catch the double click event ($NM_DBLCLK).

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I have this script and I want to run CreateIM function just for double click on any list view item. In this moment run for one click.

#include <GUIListView.au3>

Global $OFFLINE_VIEW = True
Global $ITEM[30]

Global $MAIN = GUICreate("IM",250,500,-1,-1,0x16C80000,0x00000181)
Global $LIST_VIEW = GUICtrlCreateListView("Username",5,5,240,490,BitOR(0x0004,0x0010,0x00200000))
For $INDEX = 0 To 29
    $ITEM[$INDEX] = GUICtrlCreateListViewItem("User " & $INDEX,$LIST_VIEW)
Next
Sleep(1000)
GUISetState(@SW_SHOW,$MAIN)

While True
    $MSG = GUIGetMsg()
    Switch $MSG
        Case -3
            Exit
    EndSwitch
    For $INDEX = 0 To _GUICtrlListView_GetItemCount($LIST_VIEW)-1
        If $MSG = $ITEM[$INDEX] Then
            CreateIM(_GUICtrlListView_GetItemText($LIST_VIEW,_GUICtrlListView_GetHotItem($LIST_VIEW)))
        EndIf
    Next
    Sleep(10)
WEnd

Func CreateIM($NAME)
    $GUI = GUICreate($NAME,200,200)
    GUISetState(@SW_SHOW,$GUI)
    While True
        $GUI_MSG = GUIGetMsg()
        If $GUI_MSG = -3 Then
            GUIDelete($GUI)
            ExitLoop
        EndIf
        Sleep(10)
    WEnd
EndFunc

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>



Global $OFFLINE_VIEW = True
Global $ITEM[30]

Global $MAIN = GUICreate("IM",250,500,-1,-1,0x16C80000,0x00000181)
Global $LIST_VIEW = GUICtrlCreateListView("Username",5,5,240,490,BitOR(0x0004,0x0010,0x00200000))
For $INDEX = 0 To 29
    $ITEM[$INDEX] = GUICtrlCreateListViewItem("User " & $INDEX,$LIST_VIEW)
Next
Sleep(1000)
GUISetState(@SW_SHOW,$MAIN)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While True
    $MSG = GUIGetMsg()
    Switch $MSG
        Case -3
            Exit
    EndSwitch
WEnd

Func CreateIM($NAME)
    $GUI = GUICreate($NAME,200,200)
    GUISetState(@SW_SHOW,$GUI)
    While True
        $GUI_MSG = GUIGetMsg()
        If $GUI_MSG = -3 Then
            GUIDelete($GUI)
            ExitLoop
        EndIf
        Sleep(10)
    WEnd
EndFunc
 
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
;~  Local $tBuffer
    $hWndListView = $LIST_VIEW
    If Not IsHWnd($LIST_VIEW) Then $hWndListView = GUICtrlGetHandle($LIST_VIEW)

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
    Case $hWndListView
        
        if $iCode = $NM_DBLCLK Then
                CreateIM(_GUICtrlListView_GetItemText($LIST_VIEW,_GUICtrlListView_GetHotItem($LIST_VIEW)))
        EndIf
    
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
Edited by wolf9228

صرح السماء كان هنا

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...