10

我有一个示例 Java 应用程序,当我下载javaaccessablity-2.0.2它时使用了 Java Accessibility(通过 Java Access Bridge WindowsAccessBridge-32.dll)。虽然它调用getAccessibleContextFromHWND成功它返回false。请注意,我通过检查工具验证了 hWnd 的正确值。

我的 Windows 64 位系统中安装了 64 位 Java SDK。以下是我尝试过的代码。我也尝试过使用 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);

    }
}

我已经阅读了类似的帖子,但它并没有解决我的问题。

4

1 回答 1

2

我搞定了。这与我们在构建涉及 WindowsAccessBridge dll 的项目时选择正确的目标平台组合有关。我们必须尝试大量的排列来完成这项工作。

以下链接包含代码,但您仍然需要加载正确的 dll 才能使其正常工作。

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

于 2015-07-08T09:48:31.913 回答