本文整理汇总了Java中com.sun.jna.platform.win32.WinUser.MSG类的典型用法代码示例。如果您正苦于以下问题:Java MSG类的具体用法?Java MSG怎么用?Java MSG使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MSG类属于com.sun.jna.platform.win32.WinUser包,在下文中一共展示了MSG类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createHotKeys
import com.sun.jna.platform.win32.WinUser.MSG; //导入依赖的package包/类
private void createHotKeys() {
Thread keys = new Thread(() -> {
keysThreadID = Kernel32.INSTANCE.GetCurrentThreadId();
User32.INSTANCE.RegisterHotKey(new HWND(Pointer.NULL), 1, MOD_WIN | MOD_NOREPEAT, VK_E);
MSG msg = new MSG();
while (User32.INSTANCE.GetMessage(msg, new HWND(Pointer.NULL), 0, 0) != 0 && running) {
if (msg.message == WM_HOTKEY) {
try {
switch (msg.wParam.intValue()) {
case 1:
new ProcessBuilder("explorer.exe", ",").start();
break;
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
User32.INSTANCE.UnregisterHotKey(Pointer.NULL, 1);
});
keys.start();
}
示例2: clipboardMonitor
import com.sun.jna.platform.win32.WinUser.MSG; //导入依赖的package包/类
public static void clipboardMonitor() {
WString windowClass = new WString("MyWindowClass");
HMODULE hInst = Kernel32.INSTANCE.GetModuleHandle("");
WNDCLASSEX wClass = new WNDCLASSEX();
wClass.hInstance = hInst;
WindowProc wProc = new WindowProc();
wClass.lpfnWndProc = wProc;
wClass.lpszClassName = windowClass;
// register window class
User32.INSTANCE.RegisterClassEx(wClass);
getLastError();
// create new window
HWND hWnd = User32.INSTANCE.CreateWindowEx(User32.WS_EX_TOPMOST, windowClass, "My hidden helper window, used only to catch the windows events", 0, 0, 0, 0, 0, null, null, hInst, null);
getLastError();
// set clipboard viewer
HWND nextViewer = User32X.INSTANCE.SetClipboardViewer(hWnd);
wProc.setNextViewer(nextViewer);
// pump messages
MSG msg = new MSG();
while (User32.INSTANCE.GetMessage(msg, hWnd, 0, 0) != 0) {
User32.INSTANCE.TranslateMessage(msg);
User32.INSTANCE.DispatchMessage(msg);
}
// wait for input
try {
System.in.read();
} catch (IOException e) {
e.printStackTrace();
}
// destroy window
User32.INSTANCE.UnregisterClass(windowClass, hInst);
User32.INSTANCE.DestroyWindow(hWnd);
System.exit(0);
}
示例3: initKeyHook
import com.sun.jna.platform.win32.WinUser.MSG; //导入依赖的package包/类
public void initKeyHook() {
thread = new Thread(new Runnable() {
@Override
public void run() {
final User32 lib = User32.INSTANCE;
HMODULE hMod = Kernel32.INSTANCE.GetModuleHandle(null);
keyboardHook = new LowLevelKeyboardProc() {
public LRESULT callback(int nCode, WPARAM wParam,
KBDLLHOOKSTRUCT info) {
if (nCode >= 0) {
switch (wParam.intValue()) {
// case WinUser.WM_KEYUP:
case WinUser.WM_KEYDOWN:
// case WinUser.WM_SYSKEYUP:
case WinUser.WM_SYSKEYDOWN:
// do active
userActive();
}
}
return lib.CallNextHookEx(hhk, nCode, wParam,
info.getPointer());
}
};
hhk = lib.SetWindowsHookEx(WinUser.WH_KEYBOARD_LL,
keyboardHook, hMod, 0);
// This bit never returns from GetMessage
int result;
MSG msg = new MSG();
while ((result = lib.GetMessage(msg, null, 0, 0)) != 0) {
if (result == -1) {
System.err.println("error in get message");
break;
} else {
System.err.println("got message");
lib.TranslateMessage(msg);
lib.DispatchMessage(msg);
}
}
lib.UnhookWindowsHookEx(hhk);
}
});
thread.start();
}
示例4: registerMouseUpListner
import com.sun.jna.platform.win32.WinUser.MSG; //导入依赖的package包/类
public synchronized void registerMouseUpListner(Runnable action,
Executor executor)
{
if (thrd != null)
return;
this.action = action;
thrd = new Thread(new Runnable()
{
public void run()
{
try
{
if (!isHooked)
{
hhk = USER32INST.SetWindowsHookEx(14,
(HOOKPROC) mouseHook,
KERNEL32INST.GetModuleHandle(null), 0);
isHooked = true;
MSG msg = new MSG();
while ((USER32INST.GetMessage(msg, null, 0, 0)) != 0)
{
System.out.println("got message");
USER32INST.TranslateMessage(msg);
USER32INST.DispatchMessage(msg);
System.out.print(isHooked);
if (!isHooked)
break;
}
}
else
System.out.println("The Hook is already installed.");
}
catch (Exception e)
{
System.err.println(e.getMessage());
System.err.println("Caught exception in MouseHook!");
}
// System.out.println("terminated ");
USER32INST.UnhookWindowsHookEx(hhk);
hhk = null;
}
}, "Named thread");
threadFinish = false;
thrd.start();
}
示例5: GetMessage
import com.sun.jna.platform.win32.WinUser.MSG; //导入依赖的package包/类
int GetMessage(MSG msg, HWND hwnd, int filterMin, int filterMax);
示例6: TranslateMessage
import com.sun.jna.platform.win32.WinUser.MSG; //导入依赖的package包/类
boolean TranslateMessage(MSG msg);
示例7: DispatchMessage
import com.sun.jna.platform.win32.WinUser.MSG; //导入依赖的package包/类
LRESULT DispatchMessage(MSG msg);