rajeshontheweb Posted June 16, 2009 Posted June 16, 2009 (edited) i had a major breakthrough in one of my scripts. i had to monitor list view selection changes and this might be a silly old trick for experienced people but for amateur coder, it was something great stumbled upon, thought it might be useful for people like wise. ; this will be the core. #include <GUIListView.au3> $CurrentMark = _GUICtrlListView_GetSelectionMark($lstView) Func _GUICtrlListView_Selectionchanged(ByRef $CurrentMark, $LV_CtrlID) ; Author Rajesh VR , June 2009 ; Checks for Mark change and returns if the selection has changed! ; requires <#include GUIListView.AU3> ; User needs to initialise $CurrentMark = _GUICtrlListView_GetSelectionMark($lstViewControl ) after the list view control is populated with items ; $currentMark initiation should be outside the monitoring loop (preferably a global variable) ; will return true if selection has changed, @extended will give selection value [extended isnt supporting | ???] Local $oldMark = $CurrentMark Local $NewMark = _GUICtrlListView_GetSelectionMark($LV_CtrlID) If $CurrentMark <> $NewMark Then $CurrentMark = $NewMark Return True Else Return False EndIf EndFunc ;==>_GUICtrlListView_Selectionchanged expandcollapse popup; a working demo of the UDF (shouldnt call it so yet... #include <GUIConstants.au3> #include <GUIListView.au3> #include <WindowsConstants.au3> #include <ListBoxConstants.au3> $frmMain = GUICreate("ListView Monitoring without WM Commands", 594, 269, 193, 125) $iExWindowStyle = $WS_EX_CLIENTEDGE ;BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE) $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER, $LVS_EX_TRACKSELECt, $LVS_EX_FLATSB) $lstView = GUICtrlCreateListView("Column A|Column B|Column C", 12, 92, 585, 325, -1, $iExWindowStyle) _GUICtrlListView_SetExtendedListViewStyle($lstView, $iExListViewStyle) GUICtrlCreateListViewItem("1|2|3", $lstView) GUICtrlCreateListViewItem("4|5|6", $lstView) GUICtrlCreateListViewItem("7|8|9", $lstView) $CurrentMark = _GUICtrlListView_GetSelectionMark($lstView) GUISetState(@SW_SHOW) While 1 If _GUICtrlListView_Selectionchanged($CurrentMark, $lstView) = True Then ConsoleWrite(@CRLF & "Marked Row : "& $CurrentMark & @TAB & " Selection Value " & GUIctrlREad(GuiCtrlREad($lstView)) & @cRLF) EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _GUICtrlListView_Selectionchanged(ByRef $CurrentMark, $LV_CtrlID) ; Author Rajesh VR , June 2009 ; Checks for Mark change and returns if the selection has changed! ; requires <#include GUIListView.AU3> ; User needs to initialise $CurrentMark = _GUICtrlListView_GetSelectionMark($lstViewControl ) after the list view control is populated with items ; $currentMark initiation should be outside the monitoring loop (preferably a global variable) ; will return true if selection has changed, @extended will give selection value [extended isnt supporting | ???] Local $oldMark = $CurrentMark Local $NewMark = _GUICtrlListView_GetSelectionMark($LV_CtrlID) If $CurrentMark <> $NewMark Then $CurrentMark = $NewMark Return True Else Return False EndIf EndFunc ;==>_GUICtrlListView_Selectionchanged Edited June 16, 2009 by rajeshontheweb Started late is much better than having never started it!!!!Failure is another step towards success. I've been messing around with: Adding Entry to 'Hosts'File Information Lister (Logger)Yet Another AutoIT Error Handler Yet Another AutoIT Error Handler & Debugger Control your App's TaskBar Button YCurrency Ticker (Latest Release : 16 Apr 2009)_WinInetInternetCheckConnection UDF Symantec Definitions Lister UDF _GetLocalIPAddresses UDF UDF to get Special Folder Information WMI_NetworkAdapterConfiguration2Array WMI_CDRomDriveCapabilities _ScriptExists - Check if your au3 script is running!! Uninstaller UDF Get Version for your application (at script level or compiled stage) Uninstaller Pro - faster alternative to windows application removal applet
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