728x90
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 


                  고전적인 ListBox 의 문제점 중 하나는, Line number 나 Data를 얻어 올 수 있지만 "상태에 의해 제약받는다" 는 점이 있다.
                  그 상태에 대해선 3가지 부류가 있는데.. 결론은 Selected 상태여야 한다는 것으로 귀결된다.
                   


                  'AUTOHOTKEY' 카테고리의 다른 글

                  ControlSend 와 Nox에 관한 고찰  (0) 2019.02.22
                  IniRead, IniWrite, IniDelete  (0) 2019.02.20
                  ControlGet 에 관한 고찰  (0) 2019.02.20
                  GetText from ListBox  (0) 2019.02.20
                  ControlGet  (0) 2019.02.20

                  + Recent posts