Java Access Bridge C#:仅触发 MouseClicked 事件?

发布于 2024-11-18 15:05:41 字数 1749 浏览 2 评论 0原文

我一直在摆弄 Java Access Bridge,并设法使其大部分正常工作,但有一个例外:我只能在 Java 窗口中挂钩 MouseClicked 事件。

这段代码:

[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);
}

工作没有问题。每当 Java 窗口收到 MouseClick 时,处理它的代码也会触发 - 太棒了。然而,当我尝试挂钩另一个事件时,我什么也没得到。无论发生什么事件,我都没有收到任何东西。下面是一个示例:

[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);
}

尽管根据 oracle 文档、源代码和示例,两者的调用约定和变量类型是相同的,但上述代码不会被触发。

我一直无法弄清楚任何事情,并且我尝试使用 文档 没有任何效果。我束手无策——即使对正在发生的事情有一个大概的了解也会有所帮助。

注意:如果这是每种事件类型所需的特定方法,那么我希望使用的方法是 PropertyValueChangeFP、PropertySelectionChangeFP、PropertyTextChangeFP。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花开柳相依 2024-11-25 15:05:41

您是否将函数指针设置为回调?

/* Setup */
private void InitAccessBridge()
{
    Windows_run();
    FocusGainedDelegate fgd= new FocusGainedDelegate(HandleFocusGained);
    /* right here */
    setFocusGainedFP(fgd);
}

Are you setting the function pointer as a callback?

/* Setup */
private void InitAccessBridge()
{
    Windows_run();
    FocusGainedDelegate fgd= new FocusGainedDelegate(HandleFocusGained);
    /* right here */
    setFocusGainedFP(fgd);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文