1 /*
2 * @(#)$Id: KeyboardUtils.java 689 2009-07-22 00:10:27Z bsigner $
3 *
4 * Author : Croci Michele, mcroci@gmail.com,
5 * based on a first version of Abdullah Jibaly
6 *
7 * Purpose : Example of setting an hook function for keyboard.
8 *
9 * -----------------------------------------------------------------------
10 *
11 * Revision Information:
12 *
13 * Date Who Reason
14 *
15 * Nov 14, 2007 crocimi Initial Release
16 * Nov 27, 2008 kuu Cleanup
17 *
18 * -----------------------------------------------------------------------
19 *
20 * Copyright 1999-2009 ETH Zurich. All Rights Reserved.
21 *
22 * This software is the proprietary information of ETH Zurich.
23 * Use is subject to license terms.
24 *
25 */
26
27
28 package org.ximtec.igesture.io.keyboard;
29
30 import org.ximtec.igesture.io.win32.User32;
31 import org.ximtec.igesture.io.win32.Win32;
32
33
34 /**
35 * Example of setting an hook function for keyboard. Implemented using JNA.
36 *
37 * @author Michele Croci
38 * @author Ueli Kurmann
39 */
40
41 public class KeyboardUtils {
42
43 private final static User32 user32 = Win32.USER32_INSTANCE;
44
45 /**
46 * Simulates a keyboard input
47 * @param key the key
48 * @param status the status (UP, DOWN)
49 */
50 public void keyEvent(Key key, Key status) {
51 user32.keybd_event(key.getKeyId(), 0, status.getKeyId(), 0);
52 }
53
54 }