如何在Java中使用

如何在Java中使用

本文介绍了如何在Java中使用SendMessage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,
我已经研究了如何在Java中使用WINAPI,并且我知道JNA在这方面对我们来说是一个很好的库.

我尝试使用JNA和某些WINAPI函数,并且它们对User32.instance.SendMessage(subwinHandle,User32.WM_GETTEXT,buffer.length,buffer)除外都很好用;
就像.NET开发人员在VB6,C#,...中使用的方式一样.

我想在鼠标光标下获取文本,并且可以获取以下参数:

1.当前焦点窗口的窗口句柄.
2.我可以使用x和y获得鼠标指针.


在获得上述值之后,我调用User32.instance.GetWindowTextA(winHandle, buffer, buffer.length);检索文本,但它总是返回当前窗口的标题.

通过谷歌,我发现我们必须直接发送WM_GETTEXT而不是GetWindowText,但是在将SendMessage与消息一起使用时出现错误:"java.lang.UnsatisfiedLinkError: Error looking up function ''SendMessage'': The specified procedure could not be found."


除此之外,我无法在鼠标光标处获取当前窗口的组件(如按钮,标签,编辑控件等子窗口).

我知道这个过程:获取当前窗口的处理程序,在当前窗口的鼠标光标处找到子窗口,然后发送消息,...但是仍然遇到问题.

有人可以给我一些想法,用Java在9鼠标光标下获取文本.

此致

Dear all,
I have research about how to use WINAPI in Java and I know that JNA is a good library for us in this.

I try to use JNA and some WINAPI function and they work well except to User32.instance.SendMessage(subwinHandle, User32.WM_GETTEXT, buffer.length, buffer );
like the way .NET developers use in VB6, C#,...

I want to get text under the mouse cursor and I can get bellow parameters:

1. Window handle of the current focus window.
2. I can get mouse pointer with x and y.


After I got above values, I call User32.instance.GetWindowTextA(winHandle, buffer, buffer.length); to retrieve the text but it always return the title of the current window.

Go through google I found that we must send directly WM_GETTEXT instead of GetWindowText but I got mistake when using SendMessage with message: "java.lang.UnsatisfiedLinkError: Error looking up function ''SendMessage'': The specified procedure could not be found."


Beside that, I can not get the component (childwindow like button, lable, edit control,...) of the current window at mouse cursor.

I know about the process : get handler of the current window, find the childwindow at mouse cursor of the current window, and sendmessage,... but still got problem with this.

Can some guys give me some ideas to do this 9get text under the mouse cursor) in Java.

Regards,

推荐答案



这篇关于如何在Java中使用SendMessage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 06:45