rusty1201 Posted September 28, 2008 Posted September 28, 2008 Hey guys - I've been pouring through topics on controlling a "SysListView" box and I've basically got it working, but now that I've found the item I want and have it selected I can't figure out how to actually focus it / double-click on it. Here's what I need to do: Select an item in a list box of about 3000 items (done this) Scroll down to where that selected item is (?) Double-click that item The problem is that after I select the item the box doesn't scroll itself down to the selected item, and there is no other method in the program I'm trying to automate other than double-clicking to make the selection go. If I try pressing enter or space or whatever after the item is selected by AutoIT nothing happens, I have to manually scroll down, find the item I've selected and then double-click it, which obviously isn't going to work. Here's my code so far: $gametype = "Yellow" $opts = "Large" $chnd = ControlGetHandle("Mygame", "", "SysListView322") for $i = controllistview ("Mygame", "", "SysListView322", "GetItemCount") to 1 step -1 $txt = controllistview ("Mygame", "", "SysListView322", "GetText", $i, 2) if $txt = $gametype Then $txt = controllistview ("Mygame", "", "SysListView322", "GetText", $i, 4) if $txt = $opts Then controllistview ("Mygame", "", "SysListView322", "Select", $i) msgbox (0, "", "Found and selected item!") WinActivate ("Mygame") quitnow () endIf endIf Next Any ideas??! Thanks!!
Zedna Posted October 1, 2008 Posted October 1, 2008 Try this: #Include <GuiListView.au3> $gametype = "Yellow" $opts = "Large" $chnd = ControlGetHandle("Mygame", "", "SysListView322") for $i = controllistview ("Mygame", "", "SysListView322", "GetItemCount") to 1 step -1 $txt = controllistview ("Mygame", "", "SysListView322", "GetText", $i, 2) if $txt = $gametype Then $txt = controllistview ("Mygame", "", "SysListView322", "GetText", $i, 4) if $txt = $opts Then ;~ controllistview ("Mygame", "", "SysListView322", "Select", $i) _GUICtrlListView_SetItemSelected($chnd, $i) _GUICtrlListView_ClickItem($chnd, $i) msgbox (0, "", "Found and selected item!") WinActivate ("Mygame") quitnow () endIf endIf Next Resources UDF ResourcesEx UDF AutoIt Forum Search
Nendlescap_Allien Posted July 4, 2019 Posted July 4, 2019 ;Use the function: _GUICtrlListView_EnsureVisible($idListview, $index)
Developers Jos Posted July 4, 2019 Developers Posted July 4, 2019 16 minutes ago, Nendlescap_Allien said: ;Use the function: _GUICtrlListView_EnsureVisible($idListview, $index) Could you please explain what this post is supposed to do in an 11 years old thread? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Nendlescap_Allien Posted July 14, 2019 Posted July 14, 2019 Sorry, my mistake. I had the same problem. That's how I got in here. It was my first time writing something here. I didn't notice the date. But beginners like me can have the same problem. And get in here. Now, they will see: _GUICtrlListView_EnsureVisible()
Zedna Posted July 14, 2019 Posted July 14, 2019 Just for the correct info: Function _GUICtrlListView_ClickItem() which I used in my solution uses _GUICtrlListView_EnsureVisible() so your "smart" advice is useless. Func _GUICtrlListView_ClickItem($hWnd, $iIndex, $sButton = "left", $fMove = False, $iClicks = 1, $iSpeed = 1) If $Debug_LV Then _GUICtrlListView_ValidateClassName($hWnd) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) Local $aPos, $tRect, $iX, $iY, $tPoint, $iMode _GUICtrlListView_EnsureVisible($hWnd, $iIndex, False) $tRect = _GUICtrlListView_GetItemRectEx($hWnd, $iIndex) $tPoint = _WinAPI_PointFromRect($tRect, True) $tPoint = _WinAPI_ClientToScreen($hWnd, $tPoint) _WinAPI_GetXYFromPoint($tPoint, $iX, $iY) If Not $fMove Then $iMode = Opt("MouseCoordMode", 1) $aPos = MouseGetPos() Opt("MouseCoordMode", $iMode) _WinAPI_ShowCursor(False) MouseClick($sButton, $iX, $iY, $iClicks, $iSpeed) MouseMove($aPos[0], $aPos[1], 0) _WinAPI_ShowCursor(True) Else MouseClick($sButton, $iX, $iY, $iClicks, $iSpeed) EndIf EndFunc ;==>_GUICtrlListView_ClickItem Resources UDF ResourcesEx UDF AutoIt Forum Search
Nendlescap_Allien Posted July 18, 2019 Posted July 18, 2019 (edited) Just for the correct info: None of those presented is useless. _GUICtrlListView_EnsureVisible Is a simple and faster solution. Think about it. In your solution with _GUICtrlListView_ClickItem How many lines of code are executed to get to the solution? How many functions are called within _GUICtrlListView_ClickItem ? Is it necessary to click the item first? Edited July 18, 2019 by Nendlescap_Allien Grammar Correction
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