wilix-team / iohook

Node.js global keyboard and mouse listener.
https://wilix-team.github.io/iohook
MIT License
1.2k stars 291 forks source link

Support for Latest Electron #241

Closed orfeas05 closed 3 years ago

orfeas05 commented 4 years ago

Is there any plan on making iohook compatible with the latest Electron?

I really liked using it but now I'm forced to use the newest Electron version and everything feels off without iohook.

Thanks in advance, Orfeas.

marcelblum commented 4 years ago

+1. Happy to throw some donation $$ to the maintainers if that would help make a difference @Djiit ...

Djiit commented 4 years ago

Nah, just didn't had time. I'll do this tonight.

marcelblum commented 4 years ago

whoah sweet thanks!

orfeas05 commented 4 years ago

that just made my day <3

marcelblum commented 4 years ago

really hoping that maybe https://github.com/kwhat/libuiohook/pull/72 fixes nasty #93

Djiit commented 4 years ago

It should be ok with 0.6.6, can you test it ?

defano commented 4 years ago

Thanks, @Djiit !

Added 0.6.6 to my project using Electron 80 (v9.0.5) but I get this crash immediately on launch (macOS Catalina):

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 iohook.node 0x000000010dc997af Nan::imp::FunctionCallbackWrapper(v8::FunctionCallbackInfo<v8::Value> const&) + 31 1 com.github.Electron.framework 0x00000001034783ef v8::internal::Accessors::MakeAccessor(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Name>, void (*)(v8::Local<v8::Name>, v8::PropertyCallbackInfo<v8::Value> const&), void (*)(v8::Local<v8::Name>, v8::Local<v8::Value>, v8::PropertyCallbackInfo<v8::Boolean> const&)) + 16815 2 com.github.Electron.framework 0x0000000103477911 v8::internal::Accessors::MakeAccessor(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Name>, void (*)(v8::Local<v8::Name>, v8::PropertyCallbackInfo<v8::Value> const&), void (*)(v8::Local<v8::Name>, v8::Local<v8::Value>, v8::PropertyCallbackInfo<v8::Boolean> const&)) + 14033 3 com.github.Electron.framework 0x0000000103476fa2 v8::internal::Accessors::MakeAccessor(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Name>, void (*)(v8::Local<v8::Name>, v8::PropertyCallbackInfo<v8::Value> const&), void (*)(v8::Local<v8::Name>, v8::Local<v8::Value>, v8::PropertyCallbackInfo<v8::Boolean> const&)) + 11618 4 com.github.Electron.framework 0x0000000103ea9d78 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 484168

No issues running 0.6.5 with Electron 8.2.0 (76)

ykhwong commented 4 years ago

I am having the same issue as above on Windows 10 x64. (Electron 80 : v9.0.5) It terminates immediately upon require('iohook').

Djiit commented 4 years ago

Hu, ok, I have the same. I'll revert the change to make sure nobody try to use it. I'm really sorry but don't have time to work on this right now. Any help would be more than welcome.

Djiit commented 4 years ago

nvm, the version is still OK with older versions. I'll just make it bold in the readme that we need help to support newer versions.

marcelblum commented 4 years ago

Same here, Windows 10. Simple test using https://github.com/electron/electron-quick-start and installing iohook, adding app.allowRendererProcessReuse = false and webPreferences: {nodeIntegration: true} to main.js, calling require('iohook') from the renderer crashes that process. However I am able to use this new version 0.6.6 with Electron 8.3.4 (electron-76) just fine. #93 is still a problem.

napalm00 commented 4 years ago

I was able to compile iohook on Windows 10 x64 for Electron v9.2.0 using node-gyp and it works properly, somehow compiling with cmake-js makes it crash as soon as a method call is executed (e.g NodeHookAddon.startHook) with no error printed to the console.

ykhwong commented 4 years ago

I was able to compile iohook on Windows 10 x64 for Electron v9.2.0 using node-gyp and it works properly, somehow compiling with cmake-js makes it crash as soon as a method call is executed (e.g NodeHookAddon.startHook) with no error printed to the console.

Thanks, it's working fine with the node-gyp.

renzner commented 4 years ago

I was able to compile iohook on Windows 10 x64 for Electron v9.2.0 using node-gyp and it works properly, somehow compiling with cmake-js makes it crash as soon as a method call is executed (e.g NodeHookAddon.startHook) with no error printed to the console.

Dumb question here. How did you compile it using node-gyp?

ykhwong commented 4 years ago

I was able to compile iohook on Windows 10 x64 for Electron v9.2.0 using node-gyp and it works properly, somehow compiling with cmake-js makes it crash as soon as a method call is executed (e.g NodeHookAddon.startHook) with no error printed to the console.

Dumb question here. How did you compile it using node-gyp?

I created the following files binding.gyp and uiohook.gyp before running the node-gyp to compile the iohook.

binding.gyp

{
    "targets": [{
        "target_name": "iohook",
        "win_delay_load_hook": "true",
        "type": "shared_library",
        "sources": [
            "src/iohook.cc",
            "src/iohook.h"
        ],
        "dependencies": [
            "./uiohook.gyp:uiohook"
        ],
        "include_dirs": [
            "<!(node -e \"require('nan')\")",
            "libuiohook/include"
        ],
        "configurations": {
            "Release": {
                "msvs_settings": {
                    "VCCLCompilerTool": {
                        'ExceptionHandling': 1
                    }
                }
            }
        }
    }]
}

uiohook.gyp

{
    "targets": [{
        "target_name": "uiohook",
        "type": "shared_library",
        "sources": [
            "libuiohook/include/uiohook.h",
            "libuiohook/src/logger.c",
            "libuiohook/src/logger.h",
            "libuiohook/src/windows/input_helper.h",
            "libuiohook/src/windows/input_helper.c",
            "libuiohook/src/windows/input_hook.c",
            "libuiohook/src/windows/post_event.c",
            "libuiohook/src/windows/system_properties.c"
        ],
        "include_dirs": [
            'node_modules/nan',
            'libuiohook/include',
            'libuiohook/src'
        ]
    }]
}

Build

node-gyp configure build --target=9.2.0 --arch=x64 --dist-url=https://atom.io/download/electron
renzner commented 4 years ago

Thanks :) I'll try this one.

Djiit commented 4 years ago

Hey @ykhwong , would you be interested in opening a PR that introduce node-gyp usage ? It could help us to support Electron 9 and 10 (and other versions).

Thanks!

BhuvanRohith commented 4 years ago

Any update on this. It would be really helpful for electron 9 and 10 versions.

BhuvanRohith commented 4 years ago

Thanks :) I'll try this one. Hey @renzner , were you able to successfully do a gyp build ?

ykhwong commented 4 years ago

Hey @ykhwong , would you be interested in opening a PR that introduce node-gyp usage ? It could help us to support Electron 9 and 10 (and other versions).

I opened a pull request at https://github.com/wilix-team/iohook/pull/258 Please consider removing CMakeLists.txt and cmake-js in package.json.

renzner commented 4 years ago

Thanks :) I'll try this one. Hey @renzner , were you able to successfully do a gyp build ?

Looks complicated to me. So I ended up downgrading my electron version :)

Djiit commented 4 years ago

Hey @ykhwong , many thanks ! I'll review this over the weekend.

ash0x0 commented 3 years ago

Closing as resolved.