當前位置: 首頁>>代碼示例>>Java>>正文


Java HOOKPROC類代碼示例

本文整理匯總了Java中com.sun.jna.platform.win32.WinUser.HOOKPROC的典型用法代碼示例。如果您正苦於以下問題:Java HOOKPROC類的具體用法?Java HOOKPROC怎麽用?Java HOOKPROC使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


HOOKPROC類屬於com.sun.jna.platform.win32.WinUser包,在下文中一共展示了HOOKPROC類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import com.sun.jna.platform.win32.WinUser.HOOKPROC; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
    HOOKPROC hookProc = new HOOKPROC_bg();
    HINSTANCE hInst = Kernel32.INSTANCE.GetModuleHandle(null);

    User32.HHOOK hHook = User32.INSTANCE.SetWindowsHookEx(User32.WH_KEYBOARD_LL, hookProc, hInst, 0);
    if (hHook == null)
        return;
    User32.MSG msg = new User32.MSG();
    System.err.println("Please press any key ....");
    while (true) {
        User32.INSTANCE.GetMessage(msg, null, 0, 0);
    }
}
 
開發者ID:Exslims,項目名稱:MercuryTrade,代碼行數:14,代碼來源:MainTestKeyHook.java

示例2: registerMouseUpListner

import com.sun.jna.platform.win32.WinUser.HOOKPROC; //導入依賴的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();

}
 
開發者ID:yajsw,項目名稱:yajsw,代碼行數:49,代碼來源:WindowsXPMouse.java


注:本文中的com.sun.jna.platform.win32.WinUser.HOOKPROC類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。