Giter VIP home page Giter VIP logo

libuiohook's Introduction

libUIOHook: Cross-platform keyboard and mouse hooking from userland.

build-binaires

Compiling

Prerequisites:

  • cmake
  • gcc, clang or msvc
  • x11 dependencies:
    • libx11-dev
    • libxtst-dev
    • libxt-dev
    • libxinerama-dev
    • libx11-xcb-dev
    • libxkbcommon-dev
    • libxkbcommon-x11-dev
    • libxkbfile-dev
$ git clone https://github.com/kwhat/libuiohook
$ cd libuiohook
$ mkdir build && cd build
$ cmake -S .. -D BUILD_SHARED_LIBS=ON -D BUILD_DEMO=ON -DCMAKE_INSTALL_PREFIX=../dist
$ cmake --build . --parallel 2 --target install  

Configuration

option description default
all BUILD_DEMO:BOOL demo applications OFF
BUILD_SHARED_LIBS:BOOL shared library ON
ENABLE_TEST:BOOL testing OFF
OSX USE_APPLICATION_SERVICES:BOOL framework ON
USE_IOKIT:BOOL framework ON
USE_OBJC:BOOL obj-c api ON
USE_CARBON_LEGACY:BOOL legacy framework OFF
Win32
Linux USE_EVDEV:BOOL generic input driver ON
*nix USE_XF86MISC:BOOL xfree86-misc extension OFF
USE_XINERAMA:BOOL xinerama library ON
USE_XKB_COMMON:BOOL xkbcommon extension ON
USE_XKB_FILE:BOOL xkb-file extension ON
USE_XRANDR:BOOL xrandt extension OFF
USE_XRECORD_ASYNC:BOOL xrecord async api OFF
USE_XT:BOOL x toolkit extension ON
USE_XTEST:BOOL xtest extension ON

Usage

libuiohook's People

Contributors

alvdavi avatar anthonybilinski avatar ayoubserti avatar christianfrisson avatar collinalexbell avatar hsource avatar j-delaney avatar kwhat avatar molotok-sms avatar mtrabelsi avatar munsuri avatar peslys avatar shenhongfei avatar snosme avatar swills avatar therealdreg avatar tolikpylypchuk avatar univrsal avatar zshoham avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libuiohook's Issues

Typed keys

In Mac 10.9.4 I'm seeing for every key event the message:

Failed to signal RunLoop main!

Due to CFRunLoopCopyCurrentMode returning NULL, which from the docs means that the main loop is not running although at least CFRunLoopRun is blocking on the other thread.

CFStringRef mode = CFRunLoopCopyCurrentMode(CFRunLoopGetMain());
CFRunLoopGetMain() -> 0x7f8d3ca00100, mode 0x0
CFRunLoopCopyCurrentMode(CFRunLoopGetMain()) -> mode 0x0

This is just affecting the key typed detection but it is annoying nevertheless ;)

New mouse speed source for Mac OS X > 10.10

Before El Capitain (10.11) the property was:
defaults read com.apple.universalaccess mouseDriverMaxSpeed
(values range 1-32 (slow-fast)).

But now it is:
defaults read NSGlobalDomain com.apple.mouse.scaling
values appears to be between 0.0-3.0 (slow-fast)

Original:kwhat/jnativehook#110

Bidirectional mouse overflow issue on Windows

Following the negative coordinates, the issue also occurs into the other screen direction, reporting values higher than the maximum resolution itself. For now I'm dealing with this on the application side as I wanted to avoid having static values for the resolution and/or retrieving the resolution for every event (at least not till I've done some profiling). So I thought I would let you know anyways :)

How to build this?

[~/libuiohook]$ ./bootstrap.sh
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal -I /opt/local/share/aclocal --force -I m4
aclocal: warning: couldn't open directory '/opt/local/share/aclocal': No such file or directory
autoreconf: configure.ac: tracing
autoreconf: configure.ac: not using Libtool
autoreconf: running: /usr/local/Cellar/autoconf/2.69/bin/autoconf --include=/opt/local/share/aclocal --force
configure.ac:76: error: possibly undefined macro: AC_PROG_LIBTOOL
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
configure.ac:99: error: possibly undefined macro: AC_LIBTOOL_WIN32_DLL
autoreconf: /usr/local/Cellar/autoconf/2.69/bin/autoconf failed with exit status: 1

x86 compatibility

ARM-based devices running Windows currently require 32-bit (x86) builds.

When using libuiohook in this environment (I'm testing against ia32 architecture on win32) pVkToWcharTable is null when accessed within input_helper. I believe this is due to an issue with pointer sizes.

This Stackoverflow post seems related to what's happening here. The answer indicates that utilizing the original kbd.h would work in 32-bit environments.

I did manage to populate pVkToWcharTable by making changes to input_helper.h using the original definitions fromkbd.h, but it seems there needs to be further changes inside keycode_to_unicode to accommodate a 32-bit environment.

I hope helps. This is a bit outside my competency, but I'm happy to test and provide feedback.

compiling fails on arch linux

hi,
Now that I got it working on windows, I'm back to trying on arch linux. However, when I run make (no configure errors this time, whew), it gives the following output:

/bin/sh ./libtool --tag=CC --mode=link gcc -std=gnu99 -Wall -Wextra -pedantic -Wno-unused-parameter -I./include -I./src/x11 -I./src -g -O2 -Wl,--no-undefined -Wl,--no-undefined -o libuiohook.la -rpath /usr/local/lib src/libuiohook_la-logger.lo src/x11/libuiohook_la-input_helper.lo src/x11/libuiohook_la-input_hook.lo src/x11/libuiohook_la-post_event.lo src/x11/libuiohook_la-system_properties.lo -lXinerama -lXt -lX11 -lXtst -lXtst -lX11
libtool: link: gcc -std=gnu99 -shared -fPIC -DPIC src/.libs/libuiohook_la-logger.o src/x11/.libs/libuiohook_la-input_helper.o src/x11/.libs/libuiohook_la-input_hook.o src/x11/.libs/libuiohook_la-post_event.o src/x11/.libs/libuiohook_la-system_properties.o -lXinerama -lXt -lXtst -lX11 -g -O2 -Wl,--no-undefined -Wl,--no-undefined -Wl,-soname -Wl,libuiohook.so.0 -o .libs/libuiohook.so.0.0.0
src/x11/.libs/libuiohook_la-input_hook.o: In function hook_event_proc': /home/lilmike/prog/libuiohook/src/x11/input_hook.c:589: undefined reference tohook_get_screen_info'
collect2: error: ld returned 1 exit status
Makefile:695: recipe for target 'libuiohook.la' failed
make: *** [libuiohook.la] Error 1

Anyone know what that could be about?
-Michael.

How to differentiate between two keyboards

I have two keyboards attaches to my Windows 7 computer.
Is it possible to know which keyboard sends the input when a keyboard event triggers.

I really need this function in my project.
Can anyone help me out with this.
Thanks a lot

Compiling on MacOSX 10.9.3 fails due to missing declaration

I tried to compile the project on a Mac OSX 10.9.3 and got an error at:
https://github.com/kwhat/libuiohook/blob/master/src/darwin/input_helper.c#L307

src/darwin/input_helper.c:307:2: error: use of undeclared identifier 'VC_HELP'
        VC_HELP,                                        //      114 kVK_Help
        ^
1 error generated.
make: *** [src/darwin/libuiohook_la-input_helper.lo] Error 1

VC_HELP is not contained in
https://github.com/kwhat/libuiohook/blob/master/include/uiohook.h

I managed to resolve the error by inserting VC_HELP into uiohook.h
#define VC_HELP 0x0072

The 0x0072 is just a bogus value since I have no clue what a Help-keycode on a Mac is nor if a help-key even exists.

Using libuiohook library dynamically

Hi @kwhat

I would like to use your library from a golang application. I have no knowledge of C so I have extracted the the compiled version of this library from the jnativehook.jar file. However, to use them I need the related header files and I don't which one to use. Could you please help me identifying the correct ones?

libuiohook, Windows 7, MSYS2

Hi,

I don't actually have "real" issue with this (great!) lib, but rather a request if anyone has a simple working QT application with dynamic binding available?

I am unable to get it working with my QT app :-(

I "borrowed" the code from the example and only

// Set the logger callback for library output.
hook_set_logger_proc(&logger_proc);
// Set the event callback for uiohook events.
hook_set_dispatch_proc(&dispatch_proc);

do work, while the following

hook_run()

makes my program crash. The last log output I get is:

"%s [%u]: hInst was not set by DllMain().\n"

(with vars filled in, of course).

Anyone a hint for me?

Thanks a lot!

Unable to compile master

I'm not sure if master is supposed to be compilable, 1.0 seemed to have same issue?

This is the output of ./bootstrap ./configure and make
I have all the requirements and the OS is 14.04.02 LTS Ubuntu (I also tried on my local Arch Linux install but it had the same error) I'm able to get the branch you use for Jnativehook to compile.

All terminal output below:

./bootstrap.sh: 3: [: Linux: unexpected operator
autoreconf: Entering directory .' autoreconf: configure.ac: not using Gettext autoreconf: running: aclocal --force -I m4 autoreconf: configure.ac: tracing autoreconf: running: libtoolize --copy --force libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR,config'.
libtoolize: copying file config/ltmain.sh' libtoolize: putting macros in AC_CONFIG_MACRO_DIR,m4'.
libtoolize: copying file m4/libtool.m4' libtoolize: copying filem4/ltoptions.m4'
libtoolize: copying file m4/ltsugar.m4' libtoolize: copying filem4/ltversion.m4'
libtoolize: copying file m4/lt~obsolete.m4' autoreconf: running: /usr/bin/autoconf --force autoreconf: running: /usr/bin/autoheader --force autoreconf: running: automake --add-missing --copy --force-missing autoreconf: Leaving directory.'
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for gcc option to accept ISO C99... -std=gnu99
checking for ar... ar
checking the archiver (ar) interface... ar
checking for an ANSI C-conforming const... yes
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
checking for stdint.h... (cached) yes
checking for uint64_t... yes
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by gcc -std=gnu99... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @file support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc -std=gnu99 object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc -std=gnu99 supports -fno-rtti -fno-exceptions... no
checking for gcc -std=gnu99 option to produce PIC... -fPIC -DPIC
checking if gcc -std=gnu99 PIC flag -fPIC -DPIC works... yes
checking if gcc -std=gnu99 static flag -static works... yes
checking if gcc -std=gnu99 supports -c -o file.o... yes
checking if gcc -std=gnu99 supports -c -o file.o... (cached) yes
checking whether the gcc -std=gnu99 linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking operating system... x86_64-unknown-linux-gnu (Linux Compatible)
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for X11... yes
checking for XTST... yes
checking for XRecordQueryVersion in -lXtst... yes
checking for X11/extensions/record.h... yes
checking for XT... yes
checking for XTestQueryExtension in -lXtst... yes
checking for X11/extensions/XTest.h... yes
checking for XINERAMA... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating pc/uiohook.pc
config.status: creating Makefile
config.status: creating include/config.h
config.status: include/config.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands
/bin/bash ./libtool --tag=CC --mode=link gcc -std=gnu99 -Wall -Wextra -pedantic -Wno-unused-parameter -I./include -I./src/x11 -I./src -g -O2 -Wl,--no-undefined -Wl,--no-undefined -o libuiohook.la -rpath /usr/local/lib src/libuiohook_la-logger.lo src/x11/libuiohook_la-input_helper.lo src/x11/libuiohook_la-input_hook.lo src/x11/libuiohook_la-post_event.lo src/x11/libuiohook_la-system_properties.lo -lXinerama -lXt -lX11 -lXtst -lXtst -lX11
libtool: link: gcc -std=gnu99 -shared -fPIC -DPIC src/.libs/libuiohook_la-logger.o src/x11/.libs/libuiohook_la-input_helper.o src/x11/.libs/libuiohook_la-input_hook.o src/x11/.libs/libuiohook_la-post_event.o src/x11/.libs/libuiohook_la-system_properties.o -lXinerama -lXt -lXtst -lX11 -O2 -Wl,--no-undefined -Wl,--no-undefined -Wl,-soname -Wl,libuiohook.so.0 -o .libs/libuiohook.so.0.0.0
src/x11/.libs/libuiohook_la-input_hook.o: In function hook_event_proc': /home/brad/Downloads/libuiohook-master/src/x11/input_hook.c:589: undefined reference tohook_get_screen_info'
collect2: error: ld returned 1 exit status
make: *** [libuiohook.la] Error 1

Deadlock - Darwin - Keyboard Event

When a keyboard event is handled a deadlock occurs on:
https://github.com/kwhat/libuiohook/blob/master/src/darwin/hook_callback.c#L221

I set up a small sample application in XCode to verify. Mouse events are handled well, but as soon as I hit any key on the keyboard the application doesn't output any further event logs any more.

Traced down to a deadlock in the handling procedure for keyboard events - possibly because a mutex is locked two times and never gets unlocked afterwards. When I pause the application in the debugger it shows a thread waiting at this line for the mutex to be unlocked.

I'm running a MacBook Air on OSX Maverix 10.9.3

Keep up the great work, I'm really glad I found this project :)

Build fails in MacOS

I am using the 1.1 branch, build fails on MacOS 10.15

error: too many arguments to function call, expected 0, have 3

on this line (and others)

I ran the following commands:

./bootstrap.sh
./configure
make

Sideways mouse wheel causes Floating point exception in demo_hook.c

So, I have been trying to trace the problem I have been having with jnativehook.
I made my own hotkey listener just using libuiohook and I modeled the listener after demo_hook.c

When I run demo_hook.c and do a side scroll using my macs trackpad, I get a floating point exception. Here is example output

id=9,when=47596744929742,mask=0xA000,x=295,y=163,button=0,clicks=0
id=9,when=47596762488362,mask=0xA000,x=297,y=163,button=0,clicks=0
id=9,when=47596780017010,mask=0xA000,x=298,y=163,button=0,clicks=0
id=9,when=47596797004642,mask=0xA000,x=301,y=163,button=0,clicks=0
id=9,when=47596813966610,mask=0xA000,x=303,y=163,button=0,clicks=0
id=9,when=47596831185952,mask=0xA000,x=305,y=164,button=0,clicks=0
fish: './a.out' terminated by signal SIGFPE (Floating point exception)

MacOS v10.11.5

Make fails on OS X

I get the following trying to run make in the ./boostrap.sh, ./configure, make && make install process from the docs.

> make
/bin/sh ./libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I./include     -Wall -Wextra -pedantic -Wno-unused-parameter -I./include -I./src/darwin -I./src -g -O2 -MT src/libuiohook_la-logger.lo -MD -MP -MF src/.deps/libuiohook_la-logger.Tpo -c -o src/libuiohook_la-logger.lo `test -f 'src/logger.c' || echo './'`src/logger.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I./include -Wall -Wextra -pedantic -Wno-unused-parameter -I./include -I./src/darwin -I./src -g -O2 -MT src/libuiohook_la-logger.lo -MD -MP -MF src/.deps/libuiohook_la-logger.Tpo -c src/logger.c  -fno-common -DPIC -o src/.libs/libuiohook_la-logger.o
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I./include -Wall -Wextra -pedantic -Wno-unused-parameter -I./include -I./src/darwin -I./src -g -O2 -MT src/libuiohook_la-logger.lo -MD -MP -MF src/.deps/libuiohook_la-logger.Tpo -c src/logger.c -o src/libuiohook_la-logger.o >/dev/null 2>&1
mv -f src/.deps/libuiohook_la-logger.Tpo src/.deps/libuiohook_la-logger.Plo
/bin/sh ./libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I./include     -Wall -Wextra -pedantic -Wno-unused-parameter -I./include -I./src/darwin -I./src -g -O2 -MT src/darwin/libuiohook_la-input_helper.lo -MD -MP -MF src/darwin/.deps/libuiohook_la-input_helper.Tpo -c -o src/darwin/libuiohook_la-input_helper.lo `test -f 'src/darwin/input_helper.c' || echo './'`src/darwin/input_helper.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I./include -Wall -Wextra -pedantic -Wno-unused-parameter -I./include -I./src/darwin -I./src -g -O2 -MT src/darwin/libuiohook_la-input_helper.lo -MD -MP -MF src/darwin/.deps/libuiohook_la-input_helper.Tpo -c src/darwin/input_helper.c  -fno-common -DPIC -o src/darwin/.libs/libuiohook_la-input_helper.o
src/darwin/input_helper.c:117:16: warning: 'AXAPIEnabled' is deprecated: first deprecated in OS X 10.9 [-Wdeprecated-declarations]
                is_enabled = AXAPIEnabled();
                             ^
/System/Library/Frameworks/ApplicationServices.framework/Frameworks/HIServices.framework/Headers/AXUIElement.h:49:16: note: 'AXAPIEnabled' has been explicitly marked deprecated here
extern Boolean AXAPIEnabled (void) CF_DEPRECATED_MAC(10_0, 10_9);
               ^
1 warning generated.
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I./include -Wall -Wextra -pedantic -Wno-unused-parameter -I./include -I./src/darwin -I./src -g -O2 -MT src/darwin/libuiohook_la-input_helper.lo -MD -MP -MF src/darwin/.deps/libuiohook_la-input_helper.Tpo -c src/darwin/input_helper.c -o src/darwin/libuiohook_la-input_helper.o >/dev/null 2>&1
mv -f src/darwin/.deps/libuiohook_la-input_helper.Tpo src/darwin/.deps/libuiohook_la-input_helper.Plo
/bin/sh ./libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I./include     -Wall -Wextra -pedantic -Wno-unused-parameter -I./include -I./src/darwin -I./src -g -O2 -MT src/darwin/libuiohook_la-input_hook.lo -MD -MP -MF src/darwin/.deps/libuiohook_la-input_hook.Tpo -c -o src/darwin/libuiohook_la-input_hook.lo `test -f 'src/darwin/input_hook.c' || echo './'`src/darwin/input_hook.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I./include -Wall -Wextra -pedantic -Wno-unused-parameter -I./include -I./src/darwin -I./src -g -O2 -MT src/darwin/libuiohook_la-input_hook.lo -MD -MP -MF src/darwin/.deps/libuiohook_la-input_hook.Tpo -c src/darwin/input_hook.c  -fno-common -DPIC -o src/darwin/.libs/libuiohook_la-input_hook.o
src/darwin/input_hook.c:321:6: warning: implicit declaration of function 'sysinfo' is invalid in C99 [-Wimplicit-function-declaration]
        if (sysinfo(&sys_info) == 0) {
            ^
src/darwin/input_hook.c:321:15: error: use of undeclared identifier 'sys_info'; did you mean 'sysinfo'?
        if (sysinfo(&sys_info) == 0) {
                     ^~~~~~~~
                     sysinfo
src/darwin/input_hook.c:321:6: note: 'sysinfo' declared here
        if (sysinfo(&sys_info) == 0) {
            ^
src/darwin/input_hook.c:322:15: error: use of undeclared identifier 'sys_info'; did you mean 'sysinfo'?
                timestamp = sys_info.uptime;
                            ^~~~~~~~
                            sysinfo
src/darwin/input_hook.c:321:6: note: 'sysinfo' declared here
        if (sysinfo(&sys_info) == 0) {
            ^
src/darwin/input_hook.c:322:23: error: member reference base type 'int ()' is not a structure or union
                timestamp = sys_info.uptime;
                            ~~~~~~~~^~~~~~~
src/darwin/input_hook.c:1086:17: error: conflicting types for 'hook_run'
UIOHOOK_API int hook_run() {
                ^
./include/uiohook.h:423:18: note: previous declaration is here
        UIOHOOK_API int hook_run(uint16_t listen_mask);
                        ^
1 warning and 4 errors generated.
make: *** [src/darwin/libuiohook_la-input_hook.lo] Error 1

I'm actually trying to compile jnativehooks for use with java but this library is preventing the process. Any help would be appreciated as it seems you have a great library that I would love to try using.

Request for void* argument in hook_set_logger_proc and hook_set_dispatch_proc

It's common practice to include a void* argument in callback registers and then return it in the callback to allow the application to get back to their class or struct that should handle the callback. Without it, the application is forced to use global state to manage the callback, which is less nice to work with.

IMO this would be a nice thing to add whenever the API is next updated.

some keys doesn't trigger key_typed event

Hello,

I'm facing some problems on Windows ( i didn't test on other platform yet). some keys doesn't trigger KEY_TYPED event. I'm talking here about PageUp/PageDown, Del/Insert, Home/End and F1,F2,... function keys.

KEY_RELEASED and KEY_PRESSED work correctly.

Regards,

Linux build fails if USE_XKB is not defined if it seems optional

When USE_XKB is not defined in config.h, them related headers are not included, for example in input_hook.c:

#ifdef USE_XKB
#include <xcb/xkb.h>
#include <X11/XKBlib.h>
#endif

However, if they are not included the compilation fails:

./input_hook.c:168:47: error: ‘XkbUseCoreKbd’ undeclared (first use in this function)
  if (XkbGetIndicatorState(hook->ctrl.display, XkbUseCoreKbd, &led_mask) == Success) {
                                               ^
./input_hook.c:168:47: note: each undeclared identifier is reported only once for each function it appears in
./input_hook.c: In function ‘hook_event_proc’:
./input_hook.c:317:4: warning: implicit declaration of function ‘xkb_state_update_key’ [-Wimplicit-function-declaration]
    xkb_state_update_key(state, keycode, XKB_KEY_DOWN);
    ^
./input_hook.c:317:25: error: ‘state’ undeclared (first use in this function)
    xkb_state_update_key(state, keycode, XKB_KEY_DOWN);
                         ^
./input_hook.c:317:41: error: ‘XKB_KEY_DOWN’ undeclared (first use in this function)
    xkb_state_update_key(state, keycode, XKB_KEY_DOWN);
                                         ^
./input_hook.c:412:41: error: ‘XKB_KEY_UP’ undeclared (first use in this function)
    xkb_state_update_key(state, keycode, XKB_KEY_UP);

libuihook not able to find keyboard/mouse when invoked over SSH on an UDOO Quad

I am using the Node package iohook which leverages libuiohook. The original issue was here for context. However, now that I can run iohook on the UDOO Quad ARM computer locally when run from the terminal on the physical machine, I cannot run iohook when invoking the app from a remote computer via SSH.

I was told this was an libuiohook issue so here I am.

The usage example iohook provides works when run from the terminal on the actual machine with a monitor, keyboard and mouse.

However, when disconnecting the monitor and keyboard (and even with them connected) and SSHing into the UDOO, I get this when running the usage example:

on_library_load [456]: XOpenDisplay failure!
load_input_helper [1907]: XkbGetKeyboard failed to locate a valid keyboard!
PID 7608 received SIGSEGV for address: 0x94
Error: Couldn't find per display information

Also, the intent is for this to be run on an UDOO Quad without a monitor or mouse connected, just a USB button which essentially acts as a keyboard.

Doing the reverse and SSHing into my Mac from the UDOO, I am able to run the usage example remotely on my Mac and press the USB button connected to the Mac and get the keyup event. However, doing the opposite and SSHing into my UDOO from the Mac and running the usage example provides the above error. Any ideas?

using libuiohook with other libraries that take keyboard input

Hi,
I am using allegro to get keyboard input, and really all I wanted was to get a keyboard hook on all platforms (as I am making mainly audiogames, aimed at the blind, and some screen readers, namely jaws for windows, hog the keyboard unless turned off, or an application specific hook set to override its hook). However, when I run my program with libuiohook installed, I get a bunch of log messages (btw, how to make those go away?), and allegro doesn't get any keyboard input. Any way to make allegro play nice with libuiohook?
Thanks,
-Michael.

file include/config.h.in not found

I tried to configure project using CMake but it seem that config.h.in not found.

CMake Error: File D:/work/libuiohook/include/config.h.in does not exist.
CMake Error at CMakeLists.txt:65 (configure_file):
  configure_file Problem configuring file

Error while installing libuiohook in windows xp

Hi,

I have been working with libuiook in linux for a while now, firts fo all thanks for making this great lib.

However, I need to make it run in windows, but I'm having problems installing libuiohook in windows.

This it's what I've done so far:

I install MinGW and MSYS2 and follow the step in this link

https://github.com/kwhat/jnativehook/wiki/Compiling.

After that I continue with:
./bootstrap.sh
./configure
make && make install

Everything work perfectly until the last step make && make install, when I got this error:

src/windows/input_hook.c:638:8: error: 'EVENT_OBJECT_NAMECHANGE' undeclared (first use in this function)
   case EVENT_OBJECT_NAMECHANGE:
        ^
src/windows/input_hook.c:638:8: note: each undeclared identifier is reported only once for each function it appears in
src/windows/input_hook.c: In function 'hook_run':
src/windows/input_hook.c:705:2: warning: implicit declaration of function 'SetWinEventHook' [-Wimplicit-function-declaration]
  win_event_hhook = SetWinEventHook(
  ^
src/windows/input_hook.c:706:4: error: 'EVENT_OBJECT_NAMECHANGE' undeclared (first use in this function)
    EVENT_OBJECT_NAMECHANGE, EVENT_OBJECT_NAMECHANGE,
    ^
src/windows/input_hook.c:710:4: error: 'WINEVENT_OUTOFCONTEXT' undeclared (first use in this function)
    WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS);
    ^
src/windows/input_hook.c:710:28: error: 'WINEVENT_SKIPOWNPROCESS' undeclared (first use in this function)
    WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS);
                        ^
Makefile:917: recipe for target 'src/windows/libuiohook_la-input_hook.lo' failed
make: *** [src/windows/libuiohook_la-input_hook.lo] Error 1

I really have no idea what could be caussing this error, I'm using the 1.0 version of the libuiohook.

Any idea of what could be caussing this error ??

Interference with multiple instances of uiohook

Not really a bug, but someone's using my obs-studio plugin, which loads libuiohook together with another piece of software that also uses the library (restream chat) and it causes the mouse input to slow down to a crawl.
The restream program is a node app, which doesn't have public source, but I just assume they used this version of libuiohook.

I've seen the behavior when launching two instances of the async demo. Just wondering if there's anything that I can do on my side to prevent this from happening or if there's no way to have two instances of the hook running in parallel.

How to safely call hook_stop not from a callback?

Since hook_run blocks the thread until stop is called, the only places hook_stop can be called on the same thread are in callbacks, which is what the two demos do. If an application wants to to stop hook on demand though, relying on user input to cause a callback while trying to shutdown seems unreliable.

Alternatively calling hook_stop from an outside thread looks unsafe since hooks API are not thread safe. This might not be that bad in practice since hook_run looks like it will be blocked on other library calls and not accessing its structure data after startup, but this still doesn't give any guarantees of thread safety.

A possible workaround might be to stop from the callback and inject an event from the application to force a callback, but this seems pretty convoluted.

I think the API would be easier to work with if hook_run was called periodically from the application and returned, instead of being called once and blocking, allowing the application to call other API in between checking for new keys.

demohook.exe error: Could not find keyboard map for locale

Error in demohook.exe:

refresh_locale_list [470]: GetKeyboardLayoutList(0, NULL) found 3 layouts.
refresh_locale_list [487]: Received 3 locales.
refresh_locale_list [628]: Could not find keyboard map for locale 0X00000000040A
0C0A!
refresh_locale_list [628]: Could not find keyboard map for locale 0X000000000409
0409!
refresh_locale_list [628]: Could not find keyboard map for locale 0XFFFFFFFFF029
1C01!
load_input_helper [860]: refresh_locale_list() found 0 locale(s).
id=4,when=197794244,mask=0x0,keycode=30,rawcode=0x41
refresh_locale_list [628]: Could not find keyboard map for locale 0X00000000040A
0C0A!
refresh_locale_list [628]: Could not find keyboard map for locale 0X000000000409
0409!
refresh_locale_list [628]: Could not find keyboard map for locale 0XFFFFFFFFF029
1C01!
id=5,when=197794354,mask=0x0,keycode=30,rawcode=0x41
id=5,when=0,mask=0x2,keycode=29,rawcode=0xA2
id=4,when=197803526,mask=0x0,keycode=30,rawcode=0x41
refresh_locale_list [628]: Could not find keyboard map for locale 0X00000000040A
0C0A!
refresh_locale_list [628]: Could not find keyboard map for locale 0X000000000409
0409!
refresh_locale_list [628]: Could not find keyboard map for locale 0XFFFFFFFFF029
1C01!
id=5,when=197803620,mask=0x0,keycode=30,rawcode=0x41
id=5,when=0,mask=0x202,keycode=29,rawcode=0xA2

How to reproduce error:

  1. set keyboard layout to Spanish
  2. run demohook.exe
  3. open a notepad.exe
  4. write in notepad window: A
  5. change keyboard layout to Arab
  6. write in notepad windows: the same key in keyboard (A)

(Compiled in Windows 7 x64 with MSYS64 + MINGW64)

syntax error near unexpected token `X11,'

I'm trying to install JnativeHook, and during the installation process it must install libuihook, and I've installed all the prerequisites of JNativeHook and libuihook (I think so).

After so many attempts, finally the compilation began and failed again. I don't know what more to do, I will let a screenshot here

captura de pantalla 119

[Windows][MINGW32] Missing required Windows flags

Hi,

While compiling on Windows 7, mingw32 4.8.1, I get undeclared variables and functions errors:

EVENT_OBJECT_NAMECHANGE
WINEVENT_OUTOFCONTEXT
WINEVENT_SKIPOWNPROCESS
...
SetWinEventHook
UnhookWinEvent

I had to define WINVER macro in input_hook.c in order to compile successfully.

#ifndef WINVER
    #define WINVER 0x0500
#endif

Demo programs fails to build on macOS

The demo program failed to build on macOS with error

error: use of undeclared identifier 'wint_t'

I was able to fix the error and compile successfully by including wchar.h in demo_hook.c

diff --git a/src/demo_hook.c b/src/demo_hook.c
index 0256059..8d5bfe3 100644
--- a/src/demo_hook.c
+++ b/src/demo_hook.c
@@ -26,6 +26,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <uiohook.h>
+#include <wchar.h>
 
 bool logger_proc(unsigned int level, const char *format, ...) {
 	bool status = false;

undefined reference to `hook_get_screen_info'

When issuing the "make && make install" as described, it throws the following error:

src/x11/.libs/libuiohook_la-input_hook.o: In function `hook_event_proc':
./libuiohook/src/x11/input_hook.c:589: undefined reference to `hook_get_screen_info'
collect2: error: ld returned 1 exit status
Makefile:686: recipe for target 'libuiohook.la' failed
make: *** [libuiohook.la] Error 1

maybe function name changed ?

Autoconf fails on msys2-64, windows 7 64bit

Hi,
I was just trying to compile libuiohook for a project I'm working on, and based on a comment to an issue on jninativehook, I needed to use msys2. I installed the packages mentioned in the issue, and did autoconf. The following output resulted:

configure.ac:59: error: possibly undefined macro: AM_INIT_AUTOMAKE
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
configure.ac:76: error: possibly undefined macro: AC_PROG_LIBTOOL
configure.ac:100: error: possibly undefined macro: AC_LIBTOOL_WIN32_DLL
configure.ac:369: error: possibly undefined macro: AM_CONDITIONAL

I tried automake, but it said to run autoconf again.
-Michael.

Constant EVENT_KEY_TYPED under OS X

Hello!
First of all, thanks for the great library!
I'm trying to use libuiohook with simple Qt program under OS X.
And sometimes the library starts sending EVENT_KEY_TYPED constantly.
As the result my program freezes.
I can't reproduce this bug in demo_hook app, but in my Qt app the problem arise regularly.
Here is how I'm using the library: (http://ns35.ru/tmp/hooks.cpp)
I'm starting it in separate thread.
And some logs:
(http://ns35.ru/tmp/log_failed.txt)
(http://ns35.ru/tmp/log_failed2.txt)
(http://ns35.ru/tmp/log_failed3.txt)
(http://ns35.ru/tmp/log_normal.txt)
When I had removed lines 327-395 in /libuiohook-master/src/darwin/input_hook.c the problem gone.
The problem reproduced in master and 1.0 branches, in OS X 9 and OS X 10, in debug and release library builds. The problem persists in builds with --disable-corefoundation and --disable-iokit.
I solved my problem because I don't need EVENT_KEY_TYPED messages, but I report anyway in case this would help somebody.

Setup being done on library load that requires display to be present

If being run in a headless environment, e.g. through ssh or with an application that's being unit tested on a CI server, libuiohook causes a segfault during library load:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff5ada378 in XkbGetUpdatedMap () from /usr/lib/x86_64-linux-gnu/libX11.so.6
(gdb) bt
#0  0x00007ffff5ada378 in XkbGetUpdatedMap () at /usr/lib/x86_64-linux-gnu/libX11.so.6
#1  0x00007ffff5ada4a5 in XkbGetMap () at /usr/lib/x86_64-linux-gnu/libX11.so.6
#2  0x00007ffff5a3e106 in load_input_helper (disp=0x0) at src/x11/input_helper.c:1801
#3  0x00007ffff5a3da2b in on_library_load () at src/x11/system_properties.c:475
#4  0x00007ffff7fe0b8a in call_init (l=<optimized out>, argc=argc@entry=1, argv=argv@entry=0x7fffffffe428, env=env@entry=0x7fffffffe438) at dl-init.c:72
#5  0x00007ffff7fe0c91 in call_init (env=0x7fffffffe438, argv=0x7fffffffe428, argc=1, l=<optimized out>) at dl-init.c:30
#6  _dl_init (main_map=0x7ffff7ffe190, argc=1, argv=0x7fffffffe428, env=0x7fffffffe438) at dl-init.c:119
#7  0x00007ffff7fd013a in _dl_start_user () at /lib64/ld-linux-x86-64.so.2

If this registration could be delayed until hook_run or a new setup API is called, then the application could choose to not start hook and avoid the call. As it is now, the application has to avoid linking hook, and instead load the library from code once it's verified that there's a normal display present.

No rule to make target `CMakeFiles/uiohook.dir/build'. Stop.

Anyone knows why I got the following error while trying to build and run it from CLion IDE?

/Applications/CLion.app/Contents/bin/cmake/bin/cmake --build /Users/mazik/Desktop/libuiohook/cmake-build-debug --target demo_properties -- -j 2
make[3]: *** No rule to make target `CMakeFiles/uiohook.dir/build'.  Stop.
make[2]: *** [CMakeFiles/uiohook.dir/all] Error 2
make[1]: *** [CMakeFiles/demo_properties.dir/rule] Error 2
make: *** [demo_properties] Error 2

Updates to Issue #64 (PR #69)

Hey @univrsal,

Could you please test c980b18, I made a few changes to fix these "function called through a non-compatible type" and "if this code is reached, the program will abort" warnings I was seeing. I think the changes should be okay, but I want to confirm on newer versions of OS X.

Thanks!

No CMake Support

I am dropping any plans on supporting CMake for this project. I have tried for the past week to get something building and it is far I have been unsuccessful. Working with CMake has been exceptionally painful for this project and the vague documentation is not doing me any favors. If you really want CMake support than please take a look at the cmake branch and see if you can get it working. No integration will take place until Windows, Linux and OS X successfully build with CMake and I will not be wasting any more of my time trying to get it working as there are many other issues to address.

problems with initialize_modifiers (darwin)

is this a paste error in libuiohook/src/darwin/post_event.c line 38 ? did you mean kCGEventFlagMaskCommand ?

Also on mac i had to comment out these lines at the end of the initialize_Modifiers function to make it work ( libuiohook/src/darwin/input_hook.c line 185):

// if (CGEventSourceFlagsState(kCGEventFlagMaskAlphaShift)) {
// set_modifier_mask(MASK_CAPS_LOCK);//ols: the hook doesn't start if this is called
// }
// Best I can tell, OS X does not support Num or Scroll lock.
//unset_modifier_mask(MASK_NUM_LOCK);
//unset_modifier_mask(MASK_SCROLL_LOCK); //ols: strange, but this sets both bits to 1

This lib is super useful. thanks for your work

Qt integrate with libuiohook

Hi,
we tray integrate libuiohook with Qt app and when we run app and close is we have error:
get_keyboard_layout_file [455]: RegOpenKeyEx failed to open key: "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\0"!
21:07:19: The program has unexpectedly finished.
21:07:19: The process was ended forcefully.

Can you tell me what is problem. We test on win 10 and win 7 not different.
I use: demo_hook_async.c

Thanks!

Intermittent cursor freezing at macos version High Sierra 10.13.5.

Thanks to the author for creating this library. I found a problem in the new apple system, which will block the system after my application has been running for some time.

Check the log only to find:

	22:44:48.924282 +0800	kernel	stalling for detach from IOHIDSystem
	22:45:40.949872 +0800	kernel	stalling for detach from IOHIDSystem
	22:46:00.401860 +0800	kernel	stalling for detach from IOHIDSystem
	22:46:22.239122 +0800	kernel	stalling for detach from IOHIDSystem
	22:46:47.968963 +0800	kernel	stalling for detach from IOHIDSystem
	22:47:02.971121 +0800	kernel	stalling for detach from IOHIDSystem
	22:47:53.898890 +0800	kernel	stalling for detach from IOHIDSystem
	22:48:08.900830 +0800	kernel	stalling for detach from IOHIDSystem

Every point of time is a pause. Can you help and give me any solution.

Windows post events mouse coordinates need to be normalized.

Windows mouse coordinates need to be normalized as due to MOUSEEVENTF_ABSOLUTE (1)
If MOUSEEVENTF_ABSOLUTE value is specified, dx and dy contain normalized absolute coordinates between 0 and 65,535. The event procedure maps these coordinates onto the display surface. Coordinate (0,0) maps onto the upper-left corner of the display surface; coordinate (65535,65535) maps onto the lower-right corner. In a multimonitor system, the coordinates map to the primary monitor.

I'll split the issue in two versions as for the single monitor version the fix is straightforward.

Single monitor:
It can be easily fixed by normalizing the coordinates this way:

double fScreenWidth   = GetSystemMetrics( SM_CXSCREEN )-1; 
double fScreenHeight  = GetSystemMetrics( SM_CYSCREEN )-1;
...
events[events_size].mi.dx = event->data.mouse.x * (65535.0f/fScreenWidth);
events[events_size].mi.dy = event->data.mouse.y * (65535.0f/fScreenHeight);
...
events[events_size].mi.dx = event->data.wheel.x * (65535.0f/fScreenWidth);
events[events_size].mi.dy = event->data.wheel.y * (65535.0f/fScreenHeight);

Multiple monitor:
We need to know to which monitor the coordinates x,y belong to in order to make the conversion properly as it depends on the monitor resolution (in case they are non-uniform).

So from post_event we need access to the monitor enumerator or to a valid screen_info structure.

P.S. I'll be also opening a ticket for the hook_create_screen_info (as you were done with it already?)

(1):
https://msdn.microsoft.com/en-us/library/windows/desktop/ms646273(v=vs.85).aspx

libuiohook with visual studio 2015?

Hi,
I read that visual studio 2015 has c99 support, and I even managed to compile libuiohook on it (using the command line). I was just thinking that perhaps an official project could be provided in the git repo now that visual studio does support c99.
-Michael.

deadkeys support

Hi Alex Barker (@kwhat), I have one problem with deadkeys support.

Some keys works fine, for example: ?¿@{} -> The keychar is correct: id=3,when=15251484,mask=0x1,keychar=?,rawcode=219

But when I try with a deadkey + letter dont works. For example: Á

id=4,when=16440134,mask=0x0,keycode=40,rawcode=0xDE
id=5,when=16440196,mask=0x0,keycode=40,rawcode=0xDE
id=4,when=16440258,mask=0x0,keycode=30,rawcode=0x41
id=3,when=16440258,mask=0x0
id=5,when=16440336,mask=0x0,keycode=30,rawcode=0x41

It only logs A (0x41) without UTF-16 composition.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.