2

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 HandleMouseClicked(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.

Stevoisiak
  • 23,794
  • 27
  • 122
  • 225
HeWhoWas
  • 601
  • 1
  • 10
  • 22

1 Answers1

0

Are you setting the function pointer as a callback?

/* Setup */
private void InitAccessBridge()
{
    Windows_run();
    FocusGainedDelegate fgd= new FocusGainedDelegate(HandleFocusGained);
    /* right here */
    setFocusGainedFP(fgd);
}
Stevoisiak
  • 23,794
  • 27
  • 122
  • 225
rigamonk
  • 1,179
  • 2
  • 17
  • 45
  • Yes, I was. It actually turned out that for some reason the program I was using would only fire these events at strange times. For example, AccessibleTextChanged would only fire if the user stopped typing for 300ms or so. Thanks for your help, and see my newest question for my latest Java Access Bridge related headaches :-P – HeWhoWas Sep 03 '11 at 02:53