N
N
NikParam422019-10-24 18:56:10
Qt
NikParam42, 2019-10-24 18:56:10

How to get access to UI fields of another program from a program?

There is a program with a graphical interface written using QT
Tell me how can I access another program running from my program and enter some value in any of its fields and, for example, press the "send"
button programs that receive data from the command line, but I need to submit data to UI fields

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rPman, 2019-10-24
@NikParam42

The correct way (I do not advise) is complicated, you need to identify the exact version of the components, build the appropriate application using them (only in this way it will be possible to use objects and call methods correctly) and inject its code into the process. Then you will have access to all elements and be able to do something like getText()
Wrong (recommended) - simple, simulate user actions by sending keyboard and mouse events to the window (or directly through OS tools, for example, in windows it is sending WM_... messages in win api there are corresponding methods), unfortunately in QT components are not win api objects, even the label is not one and you will just have one window with a bitmap, which means that only the screen (and text recognition from the image) and in some cases clipboard can be used to read the contents of the window, for example, the required field is EditBox, we simulate the command ctrl+a (select all text) ctrl+c (copy) and immediately read the content in your program
The second was successfully used in a project where it was necessary to receive data from programs written using VERY different tools and monitor the components of each in order to rebuild the injection code every time it was updated - it was crap.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question