Listing and reading Java application user interface controls from a .NET application

I have an application written in Java. The application has several user interface controls (text fields, grids, buttons, etc.). I need to develop a .NET application that can display user interface elements and read text data. I have no problem getting the Window handle for a Java application, but after that I got stuck.

The Java application is third-party and cannot be modified in any way. I have zero experience in Java, but a lot of experience in C #. I tried using Java Access Bridge, but it doesn't seem to work. As I understand it, a Java application should support the Java Availability API, which probably isn’t.

Please share your experience with a similar task or just point me in the right direction.

How to list / read user interface controls from outside Java VM?

+4
source share
3 answers

I have found a solution. It seems Java Access Bridge is still supported for my java application, but I could not get it working at first.

Tips:

  • WinForms needed an application to use the Java Access Bridge API, and I tried to access it from the .NET console. (WPF also needs to be supported, but I have not tested it)

  • The Windows_run method should be called inside the form constructor. . Before accessing any other API functions.

  • The Java access bridge must be included in the accessibility.properties file (folder: C: \ Program Files \ Java \ jre7 \ lib)

+1
source

The only way is to convert .NET β†’ Java or Java β†’ .NET manually, or there may be some commercial converters there. You can run the Java code inside the Java virtual machine by creating an instance, but there is no such interaction with Java, and not with COM. However, this may be useful.

0
source

You will need to do something like fooobar.com/questions/477944 / ... to get all the child windows, then use WM_GETTEXT to read the text data.

0
source

Source: https://habr.com/ru/post/1445884/


All Articles