1

I got an application written using Qt and I would like to read data in Qt listbox. It doesnt respond to LB_GETTEXT or other windows messages, is there a good way to get data from it from another process?

I have no access to Qt process, its external program. I am looking for a way to access LB contents from C#.

As it turns out there is Accessibility plugin for Qt that is supposed to provide support for required operations. However I am noob with QT and its unclear to me whether application has to be build with accessibility allowed or its a feature that can be turned on and off for any application ( or at least default build applicaiton, with accessibility not being disabled explicitly).

I have read and it says you need to run export QT_ACCESSIBILITY=1, place qt.conf file and put accessible folder to Qt app in main root. I think I dont understand completely how to turn QT_ACCESSIBILITY=1 and whever it should be enough for application to become accessible. ive added QT_ACCESSIBILITY=1 into environment variables in my computer properties, should that do the trick? Or export QT_ACCESSIBILITY=1 is something different.

Thanks

Valentin Kuzub
  • 11,703
  • 7
  • 56
  • 93
  • This is very interesting question. Could you find something useful? I know about [funq](https://github.com/parkouss/funq) and [GammaRay](https://github.com/KDAB/GammaRay/wiki/Getting-GammaRay). But they don't look like the best choice for black box QT GUI automation. – Vasily Ryabov Nov 18 '15 at 09:54

2 Answers2

2

You might want to use interprocess communication for these purposes: http://doc.qt.io/archives/qt-4.7/ipc.html

Christophe Weis
  • 2,518
  • 4
  • 28
  • 32
  • Thanks for the reply, but I think I wasn't clear enough, I am not the creator of Qt written process, its external program that I want to use from my C# program , and if I understand correctly your link doesn't provide ways to do that. – Valentin Kuzub Dec 30 '10 at 18:40
  • Yes, I assumed that you had acces to the Qt program :) –  Dec 30 '10 at 19:18
2

You can't easily do that, since Qt doesn't use standard Windows controls to implement it's widgets, thus you can't easily access it's contents using standard Windows Api methods(functions/messages/windows ipc). You will need to somehow hack trough it's memory(not really recommended) or use some gui (testing) automation tool that supports Qt like Squish.

LE: You might also want to check this hack by forcing the loading of Qt Accessible Plug-in into the application and then trying to inspect using usual tools like Microsoft's Spy++ included in Visual Studio. See 1 and 2.

Shinnok
  • 6,279
  • 6
  • 31
  • 44
  • is there a way to access Qt contents from Qt application? maybe they respond to some Qt cross process messages? (if you understand what I am saying). Maybe I could create a Qt program that would be an adapter betwen calls from my C# app to > my Qt program > make Qt calls to external process? Or that is not possible either – Valentin Kuzub Jan 21 '11 at 12:22
  • Not possible as long as you don't have access to that apps source code, since every Qt IPC method must be connected/accepted and handled at the source level. – Shinnok Jan 21 '11 at 12:35
  • Oki ill wait a little for some magic answer maybe and will grant you the bounty with sad face :) wanted some way to do the magic without much problems. How does Squish Qt version work then? if you know ( I mean how will IT interact with QT ListBox) – Valentin Kuzub Jan 21 '11 at 12:42
  • It most probably takes that ugly hack trough the applications memory approach that i mentioned above. – Shinnok Jan 21 '11 at 12:56
  • Take a look at http://qt.nokia.com/products-kr/device/qt-extended-modules/qt-ui-test-module/ though i think it refers to the Nokia Mobile Qt edition. – Shinnok Jan 21 '11 at 13:02
  • Very very interesting. I think this is getting close to some good solution. Did you ever try using this accessibility module? Is there a way for a Qt program to prevent it from working? If "hack" is installed how that would simplify my goal to read data from listbox? It would start to respond to WM_Gettext messages or ? I am excited, but I dont think I fully understand this accessibility module.. – Valentin Kuzub Jan 21 '11 at 22:50
  • Unfortuately this cannot be really considered as answer, if Qt isnt built in Accessible mode. – Valentin Kuzub Jul 27 '11 at 10:12