Get text from an MDI / ThunderRT6MDI / DataGridWndClass

Get help with using AutoHotkey and its commands and hotkeys
Heezea
Posts: 53
Joined: 30 Sep 2013, 21:33

Get text from an MDI / ThunderRT6MDI / DataGridWndClass

20 Feb 2015, 19:42

Hey guys, I've spend a solid chunk of the day searching/googling/testing/looking for a way to get text from a MDI / ThunderRT6MDI / DataGridWndClass application, but haven't had any luck. To be clear, I'm able to get many of the fields, but this one in particular I haven't been able to crack. It looks like a dropdown list, but I haven't had these issues with other DDLs in the program, so I don't think it's actually a DDL. It's like a text box that when you hit the arrow drops down a list of selections. When you choose one, it changes the value in the text box. You can also hit the first letter of the value and it will change the text box. I know that's pretty vague, but I don't know how else to describe it.

Any thoughts on what I could try?

Below, please see some test script I've run to try to get a value for this field. I've also tried using Winspector to intercept messages being sent, but there doesn't appear to be any recognizable text coming through from what I can tell.

Code: Select all

	MouseGetPos,,,,hwndMouse, 2
	ControlGetText, txtMouse,, ahk_id %hwndMouse%
	
	WinGet, hwndFocusWindow, ID,, STRUCTURE # ;This gets the HWND of the parent window, which is a control inside the main window.
	ControlGetFocus, nameFocus, ahk_id %hwndFocusWindow% ;This gets the name (NOT HWND) of the focused control within the STRUCTURE # control.
	ControlGet, hwndFocus, hwnd,, %nameFocus%, ahk_id %hwndFocusWindow% ;This gets the HWND of the focused control using the control name and the parent control HWND
	ControlGetText, txtFocus,, ahk_id %hwndFocus% ;This is giving me a value of '6' regardless of what the text displays from the (what appears to be a) dropdown menu.
	ControlGet, testFocus, List,, ahk_id %hwndFocus% 
	ControlGet, testFocus2, List, Count, ahk_id %hwndFocus%
	ControlGet, testFocus3, Selected,, ahk_id %hwndFocus%
	ControlGet, testFocus4, CurrentLine,, ahk_id %hwndFocus%
	ControlGet, testFocus5, Style,, ahk_id %hwndFocus%
	
	MsgBox, % "hwndMouse:" hwndMouse ".`n"  "txtMouse:" txtMouse ".`n" "txtFocus:" txtFocus ".`n" "hwndFocusWindow:" hwndFocusWindow ".`n" "nameFocus:" nameFocus ".`n" "hwndFocus:" hwndFocus ".`n" "testFocus:" testFocus ".`n"  "testFocus2:" testFocus2 ".`n"  "testFocus3:" testFocus3 ".`n"  "testFocus4:" testFocus4 ".`n"  "testFocus5:" testFocus5 ".`n" 
	
	;~ SendMessage, 0x188, 0, 0, ListBox1, WinTitle  ; 0x188 is LB_GETCURSEL (for a ListBox).
	SendMessage, 0x147, 0, 0, %nameFocus%, ahk_id %hwndFocusWindow%  ; 0x147 is CB_GETCURSEL (for a DropDownList or ComboBox).
	ChoicePos = %ErrorLevel%  ; It will be -1 if there is no item selected.
	MsgBox % ChoicePos ;Always yields 1
Thanks for looking.
Heezea
Posts: 53
Joined: 30 Sep 2013, 21:33

Re: Get text from an MDI / ThunderRT6MDI / DataGridWndClass

23 Feb 2015, 07:02

Just wanted to mention I went ahead and reposted to authotkey.com forum; seems there may be a bit more traffic there?
http://www.autohotkey.com/board/topic/1 ... dwndclass/
Miguel7
Posts: 186
Joined: 08 Sep 2014, 07:06

Re: Get text from an MDI / ThunderRT6MDI / DataGridWndClass

25 Feb 2015, 14:25

You know, I've been wanting to know the same thing myself. Sure OCR is an option (and one I'm working on developing, using the "Tesseract" OCR engine), but it tends to be unreliable. But most screen readers (like NVDA and JAWS) are able to read and speak the contents of those kinds of controls. So there must be another way. I've tried to get it using the simple UIA class I created, but that didn't work; UIA might still be the answer, but with custom controls like these your guess is as good as mine. :lol:
MJs
Posts: 454
Joined: 23 Sep 2014, 03:29

Re: Get text from an MDI / ThunderRT6MDI / DataGridWndClass

25 Feb 2015, 15:01

use Acc library http://www.autohotkey.com/board/topic/7 ... -09272012/
and use https://msdn.microsoft.com/en-us/librar ... 85%29.aspx to see if you can get what you need, actually I believe that it might be able to get those information, and before you start losing you hair over it, test it, either by Inspect.exe from microsoft
or by using http://www.autohotkey.com/board/topic/7 ... 012-09-20/ by (Sean and jethrow library, viewer) and see if it gets what you want, if so then take your time with it. good luck
Miguel7
Posts: 186
Joined: 08 Sep 2014, 07:06

Re: Get text from an MDI / ThunderRT6MDI / DataGridWndClass

26 Feb 2015, 08:28

That last one (the script on the old site) was pretty impressive. It says it was created with an accessibility lib and can do both UIA and MSAA (which I was working on learning anyway) - now that I know about it I'm so gonna check out that lib. :lol:

Thanks for the other ones too - I've got the Windows SDK at home so I'll have to check out "inspect". I bet it can read those funky "ThunderRT6WhateverItWas" custom controls too.
MJs
Posts: 454
Joined: 23 Sep 2014, 03:29

Re: Get text from an MDI / ThunderRT6MDI / DataGridWndClass

26 Feb 2015, 09:27

it can, but just don't go and blame it for the that label so called control, it's not your text/static control, it's not a control, it's drawn, Sure OCR is the only option without the source :o , wait, wasn't there a VB Decompiler somewhere :P
but using the Windows Accessibility is a good way for some/most of them.
which I was working on learning anyway
no reason to stop now
Miguel7
Posts: 186
Joined: 08 Sep 2014, 07:06

Re: Get text from an MDI / ThunderRT6MDI / DataGridWndClass

26 Feb 2015, 20:03

Oh believe me, I'm not. :lol:

My work revolves around accessibility and usability for blind & visually impaired end users. Some Assistive Tech (AT) software apps have proprietary scripting languages, but they're limited, and there are too many to learn when they all do the same stuff. That's why AHK is my first choice for most AT scripting projects - it's powerful, easy, and can do everything from OCR to voice recognition. I used it to make this inaccessible piece of... software work for screen readers. But there's still a lot I don't know how to do; so the more I learn on the subject, the closer I get to "one language to rule them all". :)

EDIT: And you're right about those controls being drawn. idk why the :?: developers do that - if you ask me the only good use for drawing stuff onto controls is games - but I've seen an entire application done that way! Maybe they think it adds security by preventing users from doing a copy/paste? lol
MJs
Posts: 454
Joined: 23 Sep 2014, 03:29

Re: Get text from an MDI / ThunderRT6MDI / DataGridWndClass

27 Feb 2015, 15:01

I know I'm hijacking your thread Heezea, but I hope you don't mind, since I can't test using the Acc library on that vb control, I can't add more than I had already (links :roll: ), and I hope you find the text you're seeking.
can do everything from OCR to voice recognition
http://capture2text.sourceforge.net/ is a good example and nice one.
one language to rule them all
hope you get there though it's hard. ;)
Miguel7
Posts: 186
Joined: 08 Sep 2014, 07:06

Re: Get text from an MDI / ThunderRT6MDI / DataGridWndClass

27 Feb 2015, 17:39

Thanks MJs. I'm getting closer every day, and tools like this "Capture2Text" are a huge help. :)

But getting back to the main topic (as others have said, sorry - I didn't mean to go that far off-topic lol) I think the best way to read text from any drawn control is using OCR. I'm far from an expert, but I've seen what it can do. There are posts on this forum and the old site that eplain how to do it in AHK, so that should point you in the right direction.

EDIT: OMGosh the source code for Capture2Text is written in AHK! Awesome! Okay, so now you definitely got a solid lead on reading that control :lol:.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Frosti, Google [Bot], jvalk87, scriptor2016, seba1685, TAC109 and 29 guests