简体   繁体   English

使用64位Java SDK和64位Windows在C#中为JavaAccessability运行示例Java应用

[英]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 ). 我有一个示例Java应用程序,当我下载使用Java Accessibility(通过Java Access Bridge WindowsAccessBridge-32.dll )的javaaccessablity-2.0.2时获得了。 Although it calls the getAccessibleContextFromHWND successfully it returns false . 尽管它成功调用了getAccessibleContextFromHWND但它返回false Please note that I get the correct value for hWnd which I verified through Inspect tool. 请注意,我获得了通过检查工具验证的正确的hWnd值。

I have a 64-bit Java SDK installed in my windows 64-bit system. 我在Windows 64位系统中安装了64位Java SDK。 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. 我也尝试过使用WindowsAccessBridge-64.dll,但它具有相同的行为,即vmID和_acParent返回为零而不是非零值。

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. 我读过类似的文章,但并没有解决我的问题。

I got it worked. 我知道了。 It has to do with selecting the right Target Platform combination when we are building the projects involved WindowsAccessBridge dlls. 与我们在构建涉及WindowsAccessBridge dll的项目时选择正确的目标平台组合有关。 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. 下面的链接提供了代码,但是您仍然必须加载适当的dll才能正常工作。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM