Reputation: 23
The Java Access Bridge API documentation states:
The Java Access Bridge API calls are contained in
AccessBridgeCalls.h
and to use them, you must also compile the fileAccessBridgeCalls.c
, which acts as the interface between your application andWindowsAccessBridge.dll
.
But when I tried to create a dll out of AccessBridgeCalls.h
& AccessBridgeCalls.c
, it says missing AccessBridgeDebug.h
file.
How do I call the initiateAccessBridge()
method? I am looking to perform tasks similar to JavaMonkey.exe, such as identifying components in a Java Swing application.
When I call isJavaWindow(int)
from the Access Bridge, it always returns false for all handlers.
Upvotes: 2
Views: 1411
Reputation: 2151
JAB relies on the Windows Messaging mechanism to perform inter-process communications. You have to set up a thread to run message pump loop and call initiateAccessBridge()
in that thread, otherwise some methods like isJavaWindow()
will always return false
.
Here is a C# reference:
var accessBridge = new AccessBridge();
// Use WPF UI thread if there is one
var messageLoopDispatcher = Application.Current?.Dispatcher;
if (messageLoopDispatcher == null)
{
var readyEvent = new ManualResetEvent(false);
var messageLoopThread = new Thread(() =>
{
messageLoopDispatcher = Dispatcher.CurrentDispatcher;
readyEvent.Set();
Dispatcher.Run();
});
messageLoopThread.SetApartmentState(ApartmentState.STA);
messageLoopThread.Start();
readyEvent.WaitOne();
}
messageLoopDispatcher.Invoke(() =>
{
accessBridge.Initialize();
});
Upvotes: 0