Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running sample Java app for JavaAccessability in C# with 64-bit Java SDK and 64-bit windows

I have a sample Java app that I got when I downloaded javaaccessablity-2.0.2 that makes use of Java Accessibility (via the Java Access Bridge WindowsAccessBridge-32.dll). Although it calls the getAccessibleContextFromHWND successfully it returns false. Please note that I get the correct value for hWnd which I verified through Inspect tool.

I have a 64-bit Java SDK installed in my windows 64-bit system. And the following is the code I tried. I have tried with WindowsAccessBridge-64.dll also but it gives the same behavior which is vmID and _acParent are returned as zero instead of non zero values.

class Program
{

    [return: MarshalAs(UnmanagedType.Bool)]
    [DllImport("WindowsAccessBridge-32.dll", CallingConvention = CallingConvention.Cdecl)]
    public extern static bool getAccessibleContextFromHWND(IntPtr hwnd, out Int32 vmID, out Int64 acParent);


    [DllImport("WindowsAccessBridge-32.dll", CallingConvention = CallingConvention.Cdecl, ThrowOnUnmappableChar = true, CharSet = CharSet.Unicode)]
    private extern static void Windows_run();

    [DllImport("user32.dll", SetLastError = true)]
    static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

    static void Main(string[] args)
    {
        Int32 vmID = 0;
        Int64 _acParent =0;
        Windows_run();
        IntPtr hWnd = (IntPtr)FindWindow("SunAwtFrame","Standalone SwingApp");
        bool retVal = getAccessibleContextFromHWND(hWnd, out vmID, out _acParent);

    }
}

I have read a similar post but it didn't solve my issue.

like image 703
krrishna Avatar asked Jul 02 '15 13:07

krrishna


People also ask

What do I need to compile and run the sample workflows?

Workflow — Contains sample XML files that define workflows. To compile and run the sample applications, you need to install both the Java Development Kit (JDK TM) 1.4 or later, and the WebLogic RFID Edge Server software.

What are the system requirements to compile and run sample applications?

To compile and run the sample applications, you need to install both the Java Development Kit (JDK TM) 1.4 or later, and the WebLogic RFID Edge Server software. For detailed information about system requirements, prerequisite software, and how to install WebLogic RFID Edge Server, see Installing WebLogic RFID Edge Server .

How do I call a Java method from a native application?

The whole procedure to call a Java method from native code is described in Chapter 4 in section 4.2 called "Calling Methods" in Sun's JNI guide pdf, which you can find here. Take a look at the invocation API. This enables you to load and start up a JVM from within your native application, and then to invoke methods upon it from the application.

How do I compile and run a sample program?

Run the "build" script ( build.sh or build.bat depending on your platform) from the command line. This script compiles the sample program. Run the "run" script ( run.sh or run.bat depending on your platform) from the command line. This script runs the sample program you just compiled.


1 Answers

I got it worked. It has to do with selecting the right Target Platform combination when we are building the projects involved WindowsAccessBridge dlls. We have to try lot of permutations to get this worked.

The below link has the code but you still have to load the proper dlls to get it worked.

https://github.com/jdog3/JavaAccessBridge.Net-Sample

like image 60
krrishna Avatar answered Nov 15 '22 13:11

krrishna