Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[Solved]Line number in listbox


  • Please log in to reply
3 replies to this topic
DataLife
  • Members
  • 1022 posts
  • Last active: Nov 27 2015 01:09 AM
  • Joined: 27 Apr 2008
I need to get the highlighted line number in listbox.

I am using the g label for one thing and the v associated variable for another so altsubmit won't work for me.

I know that double click puts the line number in A_EventInfo but I want to highlight a row of text then click a control button to use that text for something else.

How can I retrieve the line number?

thanks
DataLife

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

How can I retrieve the line number?


You may send LB_GETCURSEL message to the ListBox Control

Gui, Add, ListBox, w100 R9 hWndLB1,  ABC|DEF|GHI|JKL|MNO|PQR|STU|VWX|YZ
Gui, Add, Button, w100 gGetLineNumber, Get Line Number
Gui, Show,,
Return

GetLineNumber:
 SendMessage,(LB_GETCURSEL := 0x188),0,0,, ahk_id %LB1%
 LineNumber := ErrorLevel+1
 MsgBox %LineNumber%
Return

:)
kWo4Lk1.png

DataLife
  • Members
  • 1022 posts
  • Last active: Nov 27 2015 01:09 AM
  • Joined: 27 Apr 2008
You are correct. I found a post by Chris that used LB_GETCURSEL. It works great.

Any chance you know how to send a single click to a highlighted row in listbox?

Either that or make the listbox active again after I refresh the contents. I have to click on the listbox to be able to scroll with the arrow keys.

thanks again.
DataLife

DataLife
  • Members
  • 1022 posts
  • Last active: Nov 27 2015 01:09 AM
  • Joined: 27 Apr 2008
I found the answer to my previous question.

I can use controlfocus to make the listbox the active control again.
So simple, I found it in the documentation looking for something else.
example:

ControlFocus, Listbox1


thanks

DataLife