简体   繁体   中英

Java Application Window not recognized as java window in C# InterOp

I am using Java Access Bridge API with interop in C#. When trying to create a new AccessibleWindow with the hwnd obtained from the user32.dll method GetForegroundWindow() , it does not recognize the window as a java window, returning null. IsJavaWindow() returns false, but calling it a second time returns true. I tested this out with the example "SwingSet2" application.

        public void Initialize()
        {
            if(!Initialized)
            {
                accessBridge = new AccessBridge();
                var hwnd = WindowsNativeMethods.GetForegroundWindow();
                var window = accessBridge.CreateAccessibleWindow(hwnd);
                window.AccessBridge.Initialize();
                window.AccessBridge.Functions.GetAccessibleContextFromHWND(hwnd, out vmId, out mainContext);
                Initialized = true;      
            }
        }

I am also using code from this repo: Google Access Bridge

  1. Initialize() or the initialization code in general needs to called in a UI thread or a message pumping thread.
  2. Using the IntPtr from GetForegroundWindow() or GetActiveWindow() always returns false in IsJavaWindow() , but using FindWindow() works from user32.dll's methods.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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