I've been messing around with the Java Access Bridge and have managed to get most of it working, with one exception: I can only hook the MouseClicked event within the Java window.
This code:
[DllImport("WindowsAccessBridge.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static void setMouseClickedFP(MouseClickedDelegate fp);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void MouseClickedDelegate(System.Int32 vmID, IntPtr jevent, IntPtr ac);
static MouseClickedDelegate mcd;
mcd = new MouseClickedDelegate(HandleMouseClicked);
static void HandleMouseC开发者_JS百科licked(System.Int32 vmID, IntPtr jevent, IntPtr ac)
{
getVersionInfo(vmID, out vi);
releaseJavaObject(vmID, ac);
releaseJavaObject(vmID, jevent);
}
works without a problem. Whenever the Java window receives a MouseClick, the code that handles it triggers as well - fantastic. However, when I try and hook another event, I get nothing. No matter what the event, I'm not receiving anything. Here's an example:
[DllImport("WindowsAccessBridge.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static void setFocusGainedFP(FocusGainedDelegate fp);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void FocusGainedDelegate(System.Int32 vmID, IntPtr jevent, IntPtr ac);
static FocusGainedDelegate fgd;
fgd = new FocusGainedDelegate(HandleFocusGained);
static void HandleFocusGained(System.Int32 vmID, IntPtr jevent, IntPtr ac)
{
AccessibleContextInfo aci = new AccessibleContextInfo();
getAccessibleContextInfo(vmID, ac, out aci);
}
The above code does not get triggered, even though according to the oracle documentation, source, and examples, the calling convention and variable types are identical in both.
I haven't been able to figure anything out, and I've attempted to use many, many of the events provided in the documentation and nothing is working. I'm at my wits end - even a general idea as to what's happening would help.
NB: If it's a specific method required for each event type, the ones I'm looking to use are PropertyValueChangeFP, PropertySelectionChangeFP, PropertyTextChangeFP.
Are you setting the function pointer as a callback?
/* Setup */
private void InitAccessBridge()
{
Windows_run();
FocusGainedDelegate fgd= new FocusGainedDelegate(HandleFocusGained);
/* right here */
setFocusGainedFP(fgd);
}
精彩评论