Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get the index of a focused list item
#1
Supposed that an item in a SysListView32 list, for example a line of windows explorer, is focused, for example with a a.Select(SELFLAG_TAKESELECTION) statement. Is there a way, for example with a SendMessage command, to get the index of this list item. I understand that it can be done with a loop of GetListViewItemText statements but if the list is long it takes considerable time ! Any advice is welcome. Thanks in advance.
#2
Finally, I am satisfied with the following, very fast and efficient solution :

Function tempf
Trigger SF8     Help - how to add the trigger to the macro
Code:
Copy      Help
for i 0 n
,GetListViewItemText(hwl i &sp)
,err
,,_s=_error.description
,,out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
,,mac "Warning_QM" si
,,end
,if(SendMessage(hwl LVM_GETITEMSTATE i 0xffff00ff)&LVIS_SELECTED)
,,out "Index found %i" i
,,break

Any comment is appreciated
#3
Macro Macro2431
Code:
Copy      Help
int w=win("Winamp" "BaseWindow_RootWnd")
int hwl=child("List4" "SysListView32" w 0x0 "id=1001") ;;list 'Refine:'

int i=SendMessage(hwl LVM_GETNEXTITEM -1 LVNI_SELECTED) ;;or LVNI_FOCUSED, or LVNI_SELECTED|LVNI_FOCUSED
out i

But it will not work in Windows 7/8 Explorer, it does not use SysListView32.
#4
Excellent !

Many thanks Best regards.


Forum Jump:


Users browsing this thread: 1 Guest(s)