Jump to content

Screen reading external application with custom controls/dll call

Recommended Posts


I have a 3rd party application that I would like to read text from. On first glance the area I would like to read from is a ListView but the window info application states the class is SftTreeControl. Window info is not able to pull any text from the control and I have all but given up on that. I am fairly familiar with pulling text from applications and listview items but I have not been able to using standard methods or _GuiCtrlListView/_GuiCtrlTreeView functions. What I am left with is researching the custom control. 

I found a link to the documentation of the control from the company who writes it, softel http://softelvdm.com/Documentation/SftTree DLL 7 5/Topic/function_text

My thought was that I could use the softel DLL that is distributed with my 3rd party application (written by GE) to pull the text in. The link above gives a few functions that should be able to get the text of the control.  I know the function exists in the DLL because when I had the name of the function spelled wrong I would get an @error of 3. Once I got it right it now does not process past the DLL call line. When I run the applicaiton it prints out the correct Control ID to the console then it hangs up for about 10 seconds before stating that it "ended" and it never runs the ConsoleWrite line after the DLL call:

#include <Array.au3>

$hWindow = WinGetHandle("Centricity EMR -","")
$hControl = ControlGetHandle($hWindow, "",17138)

ConsoleWrite("Control ID: " & $hControl & @CRLF)

Local $test

$test2 = DllCall("SftTree_IX86_A_70.dll", "INT", "SftTree_GetText_A", "HWND", $hControl, "int", 0,  "STR*", $test)

ConsoleWrite("Error: " & @error & @CRLF & "Result: " & $test2[0])

ConsoleWrite($test & @CRLF)
ConsoleWrite($test2 & @CRLF)

Here is the output on the console:

Control ID: 0x00B216A2
!>10:42:30 AutoIt3.exe ended.rc:-1073741819
+>10:42:30 AutoIt3Wrapper Finished.


I don't know much at all about DLL calls so what I have written so far is just a shot in the dark. Any ideas would be greatly appreciated.

Share this post

Link to post
Share on other sites

It does not seem to be able to do anything with the custom control either. There are about 5 containers that it is in and it is able to highlight all of them except for the one I need and the one above it. When I run the simplespy code it is able to identify the class (SftTreeControl70) but when I try to use that variable to highlight/setfocus the red bar goes around my windows taskbar instead of the area of the application that it should. 

Even if I can get it to recognize that control, I am not sure I would be able to do anything with it because I am not trying to Automate anything, I am trying to pull out data. 

Share this post

Link to post
Share on other sites


you should try (and combine) some of the following:

As mentioned here 

int WINAPI SftTree_GetText_A(HWND hwndCtl, int index, LPSTR lpszBuffer);

for C-calling-convention in AutoIt, the cdecl is needed...

$test2 = DllCall("SftTree_IX86_A_70.dll", "INT:cdecl", "SftTree_GetText_A", "HWND", $hControl, "int", 0,  "STR*", $test)

Second parameter is an index to the " index number of the item for which text information is to be retrieved or set. ", you could try 1,2,3....

Third parameter could be a pointer to a string, try

$text_struct=dllstructcreate("char[1000]")  ;try wchar
$test2 = DllCall("SftTree_IX86_A_70.dll", "INT:cdecl", "SftTree_GetText_A", "HWND", $hControl, "int", 0,  "ptr", $text_ptr)

in the doc´s is also mentioned unicode, so you should try "wchar" instead of "char". Good luck!

Edited by AndyG

Share this post

Link to post
Share on other sites

No such luck. I switched it to cdecl and tried multiple combinations of different index integers as well as adding a struct with char and wchar and I still get the same results with autoit crashing.

Is there some sort of way to get back an error message from the crash to see what could cause it? 

Share this post

Link to post
Share on other sites

I see Centricity EMR is an application used in the medical profession.

I'm curious, whatever you are trying to do with the information in these medical records, why not just access the database directly?

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post

Link to post
Share on other sites

@JohnOne - Most of my job is pulling data from the db. What I am trying to do in this instance is setup a hotkey for a doctor that when pressed, it would determine which patient and document he was currently looking at and run a DB query to pull up additional information about that patient in a different screen. I am essentially trying to get around limitations in the EMR gui and add functionality via a separate app. 


@junkew - Take a look at my commend immediatly below his recommendation to use simplespy. It is unable to do anything with that particular control. It will not even highlight the area that the control is in.





Share this post

Link to post
Share on other sites

if simplespy, ranorex spy and inspect.exe are not helping in identifying you can only ask the dll delivering company for help and ask them why they deliver not an iaccessible or uia interface.

The DLL you try can only help if you inject it into the programspace of the exe

i stopped trying 

or search forum for inject dll

or use OCR tools 


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now