public interface User32Extra extends User32 {
User32Extra INSTANCE = (User32Extra) Native.loadLibrary("user32", User32Extra.class, W32APIOptions.DEFAULT_OPTIONS);
public HWND FindWindow(String string, String string1);
long SendMessageA(HWND hWnd, int msg, WPARAM wPAram, LPARAM lParam);
}
public class ecbot {
//http://msdn.microsoft.com/en-us/library/windows/desktop/ms645607(v=vs.85).aspx
private static int WM_KEYDOWN = 256;
public static void main(String[] args) {
HWND hWnd = User32.INSTANCE.FindWindow("Notepad", null);
System.out.println(hWnd.toString());
LPARAM lParam1 = new LPARAM(1);
LPARAM lParam0 = new LPARAM(0);
for (int i = 0; i < 1000; i++) {
WinDef.WPARAM wParam = new WinDef.WPARAM(i);
User32Extra.INSTANCE.SendMessageA(hWnd, WM_KEYDOWN, wParam, lParam1);
User32Extra.INSTANCE.SendMessageA(hWnd, WM_KEYDOWN, wParam, lParam0);
User32Extra.INSTANCE.SendMessageA(hWnd, WM_KEYDOWN, wParam, null);
}
}
}
我正在尝试向按键发送消息,寻找正确的窗口句柄,但该消息没有收到....为什么?((