找不到Java JNA sendMessage()

时间:2013-02-24 10:18:51

标签: java jna sendmessage user32

我正在尝试使用JNA (Overview)在最小化时将消息发送到应用程序或不在顶部(例如鼠标单击),并且我发现人们正在使用 com.sun.jna.platform.win32.User32。SendMessage A(hW,0x0201,0,0);

但我在这堂课中找不到这个功能。

如果我做错了,有人能给我一个如何实现它的例子吗?

CODE:

User32 user32;
Pointer hW = user32.GetForegroundWindow().getPointer();
user32.SendMessageA( hW, 0x0201, 0, 0 );

2 个答案:

答案 0 :(得分:5)

public interface User32Ext extends User32 {
User32Ext USER32EXT = (User32Ext) Native.loadLibrary("user32",

        User32Ext.class, W32APIOptions.DEFAULT_OPTIONS);

HWND FindWindowEx(HWND lpParent, HWND lpChild, String lpClassName,
        String lpWindowName);

HWND GetTopWindow(HWND hwnd);

HWND GetParent(HWND hwnd);

HWND GetDesktopWindow();

int SendMessage(HWND hWnd, int dwFlags, byte bVk, int dwExtraInfo);

int SendMessage(HWND hWnd, int Msg, int wParam, String lParam);

void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);

void SwitchToThisWindow(HWND hWnd, boolean fAltTab);

}

答案 1 :(得分:3)

您需要自己定义此功能。所有窗口功能都没有预定义。

示例:(未经测试 - 仅用于使用示例)

public interface MyUser32 extends User32 {
    MyUser32 INSTANCE = (MyUser32)Native.loadLibrary("user32", MyUser32.class, W32APIOptions.DEFAULT_OPTIONS);
    LRESULT SendMessage(HWND hWnd, int Msg, WPARAM wParam, LPARAM lParam);
}