beast Posted September 2, 2014 Share Posted September 2, 2014 (edited) I have try exemple in Autoit help and search this forum on geting selected value from _GUICtrlListView. But i don't find anything on geting selected, all exempel select from code and then somthing with _GetItemTextString or GetItemSelected. Some exemple on this forum use GetItemText with GetSelectedIndices. Can some one help me and give a simple exemple white Form, _GUICtrlListView and input, there input feld showing users mouse selected value from ListView. Edited September 2, 2014 by beast Link to comment Share on other sites More sharing options...
Jfish Posted September 2, 2014 Share Posted September 2, 2014 _GUICtrlListView_GetItemText will return the text of a ListView item or a subitem. Is that what you are after? Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
beast Posted September 3, 2014 Author Share Posted September 3, 2014 (edited) _GUICtrlListView_GetItemText will return the text of a ListView item or a subitem. Is that what you are after? Every time When i select a row in ListView, I want valu from this row into a variable, i have read some more and think i need a loop. I have try somthing like this and it look like variable is set but Input valu is not change. . . $IUser = GUICtrlCreateInput($IUser, 241, 8, 159, 21) . . . Case $hListView $Indices =_GUICtrlListView_GetSelectedIndices($hListView) $Indices = StringSplit($Indices, "|") For $IX = 1 To $Indices[0] Step 1 $TXTITEM =_GUICtrlListView_GetItemText($hListView, int($Indices[$IX])) $DlgItem = _WinAPI_SetFocus(_WinAPI_GetDlgItem($hwnd, $hListView)) $ItemFocused = _GUICtrlListView_GetItemFocused($hListView, int($Indices[$IX])) if $ItemFocused = True Then $IUser2 = $TXTITEM Next $IUser = GUICtrlSetData($IUser,$Iuser2) Edited September 3, 2014 by beast Link to comment Share on other sites More sharing options...
beast Posted September 9, 2014 Author Share Posted September 9, 2014 Every time When i select a row in ListView, I want valu from this row into a variable, i have read some more and think i need a loop. I have try somthing like this and it look like variable is set but Input valu is not change. . . $IUser = GUICtrlCreateInput($IUser, 241, 8, 159, 21) . . . Case $hListView $Indices =_GUICtrlListView_GetSelectedIndices($hListView) $Indices = StringSplit($Indices, "|") For $IX = 1 To $Indices[0] Step 1 $TXTITEM =_GUICtrlListView_GetItemText($hListView, int($Indices[$IX])) $DlgItem = _WinAPI_SetFocus(_WinAPI_GetDlgItem($hwnd, $hListView)) $ItemFocused = _GUICtrlListView_GetItemFocused($hListView, int($Indices[$IX])) if $ItemFocused = True Then $IUser2 = $TXTITEM Next $IUser = GUICtrlSetData($IUser,$Iuser2) No one Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 9, 2014 Moderators Share Posted September 9, 2014 beast,How about this?expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <GuiListView.au3> ; Variable to hold selected row content Global $sRowContent $hGUI = GUICreate("Test", 500, 500) $cLV = GUICtrlCreateListView("", 10, 10, 480, 250) For $i = 0 To 3 _GUICtrlListView_AddColumn($cLV, "Col " & $i, 115) Next For $i = 0 To 9 GUICtrlCreateListViewItem($i & "-0|" & $i & "-1|" & $i & "-2|" & $i & "-3|", $cLV) Next ; Create a dummy conteol to fire when the selection changes $cItemSelected = GUICtrlCreateDummy() GUISetState() ; Register WM_NOTIFY GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cItemSelected ; Selection changed so display contetn of new row MsgBox($MB_SYSTEMMODAL, "Selected", $sRowContent) EndSwitch WEnd Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int;int", $lParam) Switch BitAND(DllStructGetData($tStruct, 3), 0xFFFFFFFF) ; Code Case $NM_CLICK $sRowContent = _GUICtrlListView_GetItemTextString($cLV, DllStructGetData($tStruct, 4)) ; Row ; Fire dummy control GUICtrlSendToDummy($cItemSelected) EndSwitch EndFuncPlease ask if you have any questions. 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...
beast Posted September 10, 2014 Author Share Posted September 10, 2014 beast, How about this? expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <GuiListView.au3> ; Variable to hold selected row content Global $sRowContent $hGUI = GUICreate("Test", 500, 500) $cLV = GUICtrlCreateListView("", 10, 10, 480, 250) For $i = 0 To 3 _GUICtrlListView_AddColumn($cLV, "Col " & $i, 115) Next For $i = 0 To 9 GUICtrlCreateListViewItem($i & "-0|" & $i & "-1|" & $i & "-2|" & $i & "-3|", $cLV) Next ; Create a dummy conteol to fire when the selection changes $cItemSelected = GUICtrlCreateDummy() GUISetState() ; Register WM_NOTIFY GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cItemSelected ; Selection changed so display contetn of new row MsgBox($MB_SYSTEMMODAL, "Selected", $sRowContent) EndSwitch WEnd Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int;int", $lParam) Switch BitAND(DllStructGetData($tStruct, 3), 0xFFFFFFFF) ; Code Case $NM_CLICK $sRowContent = _GUICtrlListView_GetItemTextString($cLV, DllStructGetData($tStruct, 4)) ; Row ; Fire dummy control GUICtrlSendToDummy($cItemSelected) EndSwitch EndFunc Please ask if you have any questions. M23 All exemple when valu is in MsgBox works for me to, if I use this in my code if $ItemFocused = True Then MsgBox(4160, "Information", "Item Focused: " & $TXTITEM) It work, but cant get this valu in my InputBox >>>$IUser = GUICtrlCreateInput($IUser, 241, 8, 159, 21)<<<<< is it not posible to change the input valu on the fly and it while update for user. I list username from AD in my ListView and when user select from it it sholde update the InputBox.. I was thinking if $ItemFocused = True Then $IUser2 = $TXTITEMNext$IUser = GUICtrlSetData($IUser,$Iuser2) sholde update $IUser in my InputeBox. Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted September 10, 2014 Moderators Solution Share Posted September 10, 2014 beast,Just replace the MsgBox line with a GUICtrlSetData line: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <GuiListView.au3> ; Variable to hold selected row content Global $sRowContent $hGUI = GUICreate("Test", 500, 500) $cLV = GUICtrlCreateListView("", 10, 10, 480, 250) For $i = 0 To 3 _GUICtrlListView_AddColumn($cLV, "Col " & $i, 115) Next For $i = 0 To 9 GUICtrlCreateListViewItem($i & "-0|" & $i & "-1|" & $i & "-2|" & $i & "-3|", $cLV) Next ; Create an input $IUser = GUICtrlCreateInput("", 10, 300, 159, 21) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ; Create a dummy control to fire when the selection changes $cItemSelected = GUICtrlCreateDummy() GUISetState() ; Register WM_NOTIFY GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cItemSelected ; Selection changed so change input content GUICtrlSetData($IUser, $sRowContent) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ;MsgBox($MB_SYSTEMMODAL, "Selected", $sRowContent) EndSwitch WEnd Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int;int", $lParam) Switch BitAND(DllStructGetData($tStruct, 3), 0xFFFFFFFF) ; Code Case $NM_CLICK $sRowContent = _GUICtrlListView_GetItemTextString($cLV, DllStructGetData($tStruct, 4)) ; Row ; Fire dummy control GUICtrlSendToDummy($cItemSelected) EndSwitch EndFuncM23 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