当前位置: 首页>>代码示例>>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;未经允许,请勿转载。