1 回答

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超4個贊
jna-platform-4.0.0.jar
創(chuàng)建自定義Myuser32接口
int SendMessage(HWND hWnd, int Msg, int wParam, String lParam);
static Myuser32 INSTANCE = (Myuser32) Native.loadLibrary("user32",Myuser32.class, W32APIOptions.DEFAULT_OPTIONS);
Myuser32庫的實(shí)例
發(fā)送接口函數(shù)
獲得user32庫的實(shí)例
static User32 user32 = User32.INSTANCE;
static Myuser32 myuser32 = Myuser32.INSTANCE;
(User32)用來查找窗口,(Myuser32)用來發(fā)送消息
獲取當(dāng)前窗口句柄
HWND h = user32.FindWindow(windowClass, title);
windowClass:窗口類型;
title:窗口標(biāo)題;
兩個參數(shù)允許其中一個為null
發(fā)送消息
Send_Msg_Windows(h, msg);
h:窗口句柄
msg:待發(fā)送消息
添加回答
舉報