简体   繁体   中英

Java JNA sendMessage() not found

I'm trying to use JNA (Overview) to send messages to an application when minimized or not on top (mouse click for example), and the I found that people are using com.sun.jna.platform.win32.User32. SendMessage A( hW, 0x0201, 0, 0);

But i can't found this function in this class.

Can someone give me an example of how to implement it if I'm doing it wrong?

CODE:

User32 user32;
Pointer hW = user32.GetForegroundWindow().getPointer();
user32.SendMessageA( hW, 0x0201, 0, 0 );
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);

}

You need to define this function yourself. All windows functions are not predefined.

Example: (untested - usage example only)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM