David Andersen
  • Guests
    •  Last active:
    • Joined: --
    I really need to read the text in a ListBox. My script is as follows:
    #x::
    SendMessage, 0x189, 2, 0, WindowsForms10.LISTBOX.app.0.378734a1, Form1
    if ErrorLevel <> FAIL
    {
    MsgBox, %ErrorLevel%
    }

    Where 0x189 refers to the following MSDN function:
    http://msdn.microsof... ... ettext.asp

    at least according to http://www.codeguru.... ... .php/c2771

    Anyways... My problem is that this returns the length of the string in the listbox (this is in accordance with the description of LB_GETTEXT on MSDN. My quesiton is how I could retreave the content that lParam is pointing at after this sendmessage function.

    The following is a link to an .exe file that made in Visual Studio 2005 beta 2 (hope it works for you), containing the listbox that I am trying to retreave the text from. http://www.translati...ds.com/demo.exe.

    Thanks 


    Chris
    • Administrators
    • 10727 posts
        •  Last active:
        • Joined: 02 Mar 2004

        I really need to read the text in a ListBox.

        Have you tried "ControlGet, List"? This is a relatively recent feature that gets a complete list of items from a ListBox, ComboBox, or DropDownList. 
        David Andersen
        • Guests
          •  Last active:
          • Joined: --
          Thanks for the replay, Chris.

          I have tried the following script:
          ControlGet, List, List,, WindowsForms10.LISTBOX.app.0.378734a1, Form1 
          Loop, Parse, List, `n
          {
          MsgBox Item number %A_Index% is %A_LoopField%.
          }

          Unfortunatelly, I did not receive any output at all. 

          While I got a message box saying "5" with the following script:
          SendMessage, 0x189, 2, 0, WindowsForms10.LISTBOX.app.0.378734a1, Form1 
          if ErrorLevel <> FAIL 

          MsgBox, %ErrorLevel% 
          }

          5 represents the number of characters in this entry in the list. 
          Chris
          • Administrators
          • 10727 posts
              •  Last active:
              • Joined: 02 Mar 2004
              ControlGet is only designed to work with standard ListBoxes and ComboBoxes. Yours control seems like a non-standard (custom) control, which might explain why it doesn't work.

              Although I'm all out of ideas, I hope you find a solution or that someone else comes along who knows something. 


              그렇다! Chris 의 말대로라면 ControlGet 은 standard ListBoxes and ComboBoxes 에 디자인된 것이다. (어쨋든 여기서 필자의 요구조건은 충족시키므로 패스!)



              더욱 흥미로운 Chris 의 발언들을 살펴보자!


              David Andersen
              • Guests
                •  Last active:
                • Joined: --
                I understand. The control that I am using is the standard one used by Visual Studio 2005 (although, I am using the beta 2 version).

                Although I don't know C++ I found the method that would need some adjustments to make it possible to receive the text. Its name is ScriptSendMessage and it is located in Script2.cpp. This method uses the MSDN method SendMessageTimeout (http://msdn.microsoft.com/library/defau ... ettext.asp).

                Are there any C++ experts out there that knows how to implement this?

                Thanks a lot in advance. 
                Chris
                • Administrators
                • 10727 posts
                    •  Last active:
                    • Joined: 02 Mar 2004
                    I don't see how any internal changes to SendMessage would help in this case. The "ControlGet List" method I mentioned
                    earlier already uses LB_GETTEXT internally. If it fails to work on a custom ListBox, you would have to find out what
                    messages to send to that particular type of ListBox to get the text out of it.

                    Microsoft Active Accessibility might be able to extract text from many types of custom controls, but I don't know much
                    else about it yet. 

                    ControlGet List method 는 내부적으로 LB_GETTEXT 를 사용한다고 되어있다. 그렇다는 것은 DllCall 에 의해서도 충분히 얻어질 수 있다는 것이다!


                    이와같이 말이다.


                    LBCount := DllCall("SendMessage", "uint", hIDLB, "uint", 0x18B) ;LB_GETCOUNT




                    David Andersen
                    • Members
                    • 140 posts
                        •  Last active: Jun 28 2011 04:54 PM
                        • Joined: 15 Jul 2005
                        Thank you a lot for your help. I have sent you 10 dollars to your email address to show my appreciation.

                        I have a far more general question now. Is it in principle possible to extract the text from any listbox or combobox? I understand that i.e. Java programs are build up in a totally different way, so my question is just about the programs that show up as listboxes in AU3_Spy.

                        I really need to read text from a range of listboxes where the one at http://www.translati...ds.com/demo.exe is an example of one of them. I think that all the listboxes I want to read from have been programmed in Visual Studio.

                        I have also thought about using OCR technology to "read" the text off the screen, but this is a really dirty way to solve the problem so I hope there are other possibilities.

                        Thanks again. 
                        Chris
                        • Administrators
                        • 10727 posts
                            •  Last active:
                            • Joined: 02 Mar 2004

                            Is it in principle possible to extract the text from any listbox or combobox?

                            Since any custom control can arbitrarily contain the word ListBox or ComboBox in its name, I would have to say "no".
                            An application can be designed to store its text privately and draw it on the screen only as needed. In such a case, there
                            would be no external/direct access to the text (other than something fairly difficult such as ReadProcessMemory).

                            I have also thought about using OCR technology to "read" the text off the screen

                            This may be the best approach in this case. Here is a nice command line OCR tool that daonlyfreez recently posted:
                            Optical Character Recognition (OCR) - gocr [CLI] 



                            'AUTOHOTKEY' 카테고리의 다른 글

                            IniRead, IniWrite, IniDelete  (0) 2019.02.20
                            Line number in listbox  (0) 2019.02.20
                            ControlGet 에 관한 고찰  (0) 2019.02.20
                            ControlGet  (0) 2019.02.20
                            ListBox Count  (0) 2019.02.20

                            + Recent posts