Jump to content

listview help


Recommended Posts

HI

How to do listview that shows open window names as listview items?

What have you tried so far?
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

ok now i got main part

BUT how to make these items clickable ?

I want action on click list view item

if window is up then minimize

if window is minimized them restore

how to to it?

#include <GUIConstants.au3>
$var = WinList()


#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 454, 193, 115)
$List1 = GUICtrlCreateListView("windows", 10, 10, 600, 400)
For $i = 1 to $var[0][0]
      If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then
$list2 = GUICtrlCreateListViewItem ($var[$i][0],$List1)
GUISetState(@SW_SHOW)
 EndIf
Next
#EndRegion ### END Koda GUI section ###

Func IsVisible($handle)
  If BitAnd( WinGetState($handle), 2 ) Then 
    Return 1
  Else
    Return 0
  EndIf

EndFunc

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
Link to comment
Share on other sites

Problem detected :

Only last last item has action

its Program Manager for me , nothing happens if i click on other items

Try this.

#include <GUIConstants.au3>
#include <guilistview.au3>
$var = WinList()


#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 500, 193, 115)
$List1 = GUICtrlCreateListView("windows                               ", 10, 10, 600, 400)
Dim $list2[$var[0][0] + 1]
For $i = 1 To $var[0][0]
    If $var[$i][0] <> "" And IsVisible($var[$i][1]) Then
        $list2[$i] = GUICtrlCreateListViewItem($var[$i][0], $List1)
        GUISetState(@SW_SHOW)
    EndIf
Next
$edit1 = GUICtrlCreateEdit('',20,420,400,40)
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")
Func IsVisible($handle)
    If BitAND(WinGetState($handle), 2) Then
        Return 1
    Else
        Return 0
    EndIf

EndFunc ;==>IsVisible

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $List1
            ConsoleWrite("list1 clicked" & @CRLF)
        
    EndSwitch
WEnd

Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
        Local $tagNMHDR, $event
        $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code)
        If @error Then Return
        $event = DllStructGetData($tagNMHDR, 3)
        Select
            Case $wParam = $List1

                Select
                    Case $event = $NM_CLICK
                        Local $tagNMITEMACTIVATE = DllStructCreate("int;int;int;int;int;int;int;int;int", $lParam)
                        $selected = DllStructGetData($tagNMITEMACTIVATE, 4)
                        $selcol = DllStructGetData($tagNMITEMACTIVATE, 5)
            
                        $seltxt = StringSplit(GUICtrlRead(GUICtrlRead($List1)),'|')
                        
                        GUICtrlSetData($Edit1, $seltxt[1 + $selcol])
                EndSelect
        EndSelect
        
        Return $GUI_RUNDEFMSG

EndFunc ;==>WM_Notify_Events

EDIT: Removed some code left in by mistake

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Thanks but I dont understand how it works, can you tell me please?

Here is parts that i dont understand

Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)

If ControlGetFocus('Testing') <> 'Edit1' Then

#forceref $hWndGUI, $MsgID, $wParam

Local $tagNMHDR, $event

$tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code)

If @error Then Return

$event = DllStructGetData($tagNMHDR, 3)

Select

Case $wParam = $List1

Select

Case $event = $NM_CLICK

Local $tagNMITEMACTIVATE = DllStructCreate("int;int;int;int;int;int;int;int;int", $lParam)

$selected = DllStructGetData($tagNMITEMACTIVATE, 4)

$selcol = DllStructGetData($tagNMITEMACTIVATE, 5)

$seltxt = StringSplit(GUICtrlRead(GUICtrlRead($List1)),'|')

GUICtrlSetData($Edit1, $seltxt[1 + $selcol])

EndSelect

EndSelect

Return $GUI_RUNDEFMSG

EndIF

EndFunc ;==>WM_Notify_Events

For $i = 1 To $var[0][0]

If $var[$i][0] <> "" And IsVisible($var[$i][1]) Then

$list2[$i] = GUICtrlCreateListViewItem($var[$i][0], $List1)

I am very thankful if you could tell me how it works so i dont have to ask every little thing :)
Link to comment
Share on other sites

Thanks but I dont understand how it works, can you tell me please?

It's explained here.

Look for NM_CLICK (list view) on that page and follow the links.

BTW the function I posted had some extra lines left in by mistake and I've removed them now.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...