Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Electron 9, 10 and 11 #258

Merged
merged 52 commits into from
Dec 8, 2020
Merged

Support Electron 9, 10 and 11 #258

merged 52 commits into from
Dec 8, 2020

Conversation

ykhwong
Copy link
Contributor

@ykhwong ykhwong commented Nov 5, 2020

Description

Build iohook for electron 9 and 10

Motivation and Context

For details, please refer to #241

@Djiit Djiit self-requested a review November 6, 2020 07:40
@Djiit
Copy link
Collaborator

Djiit commented Nov 6, 2020

Hey @ykhwong, Thanks for all this work, this is awesome.
Could you please provide a "build" script ? i.e. the build script is still using cmale-js and I don't know how to replace it.

Thanks

@Djiit
Copy link
Collaborator

Djiit commented Nov 6, 2020

Allright, I've removed cmake-js, added fs-extra dev dependency on my local machine. Can't push on your branch. Now, I have this error:
make: *** No rule to make target Release/obj.target/uiohook/build_def/darwin/libuiohook/src/logger.o', needed by Release/uiohook.dylib'. Stop.

Any idea ?

@ykhwong
Copy link
Contributor Author

ykhwong commented Nov 6, 2020

Allright, I've removed cmake-js, added fs-extra dev dependency on my local machine. Can't push on your branch. Now, I have this error:
make: *** No rule to make target Release/obj.target/uiohook/build_def/darwin/libuiohook/src/logger.o', needed by Release/uiohook.dylib'. Stop.

Any idea ?

The error occurred because node-gyp could not handle symbolic .gyp links properly on Linux and macOS. I fixed the issue by copying the gyp files manually.

Encountered another weird error on travis-ci though: gyp ERR! stack Error: ENOENT: no such file or directory, mkdir '/home/travis/.cache/node-gyp/4.0.4'

@ykhwong
Copy link
Contributor Author

ykhwong commented Nov 8, 2020

I assumed that rpath does not get resolved properly, so instructed the node-gyp to get the correct path of the iohook module. Could you try again with the last commit, please?

Here are commands that I executed for testing:

node-v10 on Ubuntu x64

npm i --no-scripts
npm run build -- --runtime=node --version=10.0.0 --abi=64
mkdir -p builds/node-v64-linux-x64/build/Release/
cp build/Release/* builds/node-v64-linux-x64/build/Release/.
rm -rf build/Release
npm run test

electron-v9.0.0 on Ubuntu x64

npm i --no-scripts
npm run build -- --runtime=electron --version=9.0.0 --abi=80
mkdir my-electron-app && cd my-electron-app
npm init -y
npm install [email protected] --save
npm install iohook --save
mkdir -p ./node_modules/iohook/builds/electron-v80-linux-x64/build/Release
cp -rfp ../build/Release/* ./node_modules/iohook/builds/electron-v80-linux-x64/build/Release/.
echo 'console.log("test");'>>index.js
echo 'require("iohook");'>>index.js
./node_modules/electron/dist/electron .

@lanye74
Copy link

lanye74 commented Nov 25, 2020

Any update on this? I've been digging around the web for any solution to electron + iohook (build documentation is poor) without going back too far in electron versions

@Djiit
Copy link
Collaborator

Djiit commented Dec 1, 2020

Hey, I didn't have time to re-test everything. Last time I did, I was not able to have the same result. If anyone wants to help, we need to validate the author's change before merging and releasing a new version.

@marcelblum
Copy link
Contributor

marcelblum commented Dec 2, 2020

Hello, I took a stab at some testing tonight building on macOS 10.13 and Windows 10 and had (mostly) success with Electron 9:

Untitled

Screen Shot 2020-12-02 at 12 32 17 AM

(also made a new Electron example demo app for testing which I found helpful, it uses iohook directly in the renderer process which has several advantages, in case you want to try it I submitted a pr #265)

Some issues I observed:

  • when npm installing on both Win & Mac there were lots of errors related to robotjs. Didn't seem to impede building though.

  • After starting iohook from the Electron example there is a ton of logging noise in the node console, see pics above. Not sure if this is intentional, maybe invoking iohook via ./index.js activates some verbose debugging mode? Excuse my ignorance if this is expected but I never saw this with the previous release 0.6.6.

  • On Windows some keyboard keys are not triggering iohook keydown events, though they do produce logging output in the node console: Testing with a full USA QWERTY keyboard, all "navigation keys" (insert, home, arrows, etc.) and function keys are ignored, and also if numlock is off all numpad keys are ignored as well. These keys were all trapped successfully in the previous release 0.6.6.

  • On Mac also some keys are not being trapped: Testing with a small laptop keyboard (13" Macbook Pro w/Touchbar), the down arrow and all touchbar-forced function keys are ignored. As above, these key events are still all logged in the node console, and these keys were all working fine in the previous release 0.6.6. Did not yet get a chance to test on Mac with a full keyboard.

  • On Windows the node console often showed the following message, not sure if this is expected but I never saw it with the previous release: "Restarting Windows input hook on window event: 0X800C."

@marcelblum
Copy link
Contributor

marcelblum commented Dec 2, 2020

Update: Tested on Mac today with a full size generic USB keyboard. The following keys are not firing keydown events (but as noted above are producing logging output in the Node console): all F-keys, down arrow, insert, home, end, pgup, pgdown. So not exactly the same keys not working in Windows with this build.

@majidbigdeli
Copy link

Hello, I took a stab at some testing tonight building on macOS 10.13 and Windows 10 and had (mostly) success with Electron 9:

Untitled

Screen Shot 2020-12-02 at 12 32 17 AM

(also made a new Electron example demo app for testing which I found helpful, it uses iohook directly in the renderer process which has several advantages, in case you want to try it I submitted a pr #265)

Some issues I observed:

  • when npm installing on both Win & Mac there were lots of errors related to robotjs. Didn't seem to impede building though.
  • After starting iohook from the Electron example there is a ton of logging noise in the node console, see pics above. Not sure if this is intentional, maybe invoking iohook via ./index.js activates some verbose debugging mode? Excuse my ignorance if this is expected but I never saw this with the previous release 0.6.6.
  • On Windows some keyboard keys are not triggering iohook keydown events, though they do produce logging output in the node console: Testing with a full USA QWERTY keyboard, all "navigation keys" (insert, home, arrows, etc.) and function keys are ignored, and also if numlock is off all numpad keys are ignored as well. These keys were all trapped successfully in the previous release 0.6.6.
  • On Mac also some keys are not being trapped: Testing with a small laptop keyboard (13" Macbook Pro w/Touchbar), the down arrow and all touchbar-forced function keys are ignored. As above, these key events are still all logged in the node console, and these keys were all working fine in the previous release 0.6.6. Did not yet get a chance to test on Mac with a full keyboard.
  • On Windows the node console often showed the following message, not sure if this is expected but I never saw it with the previous release: "Restarting Windows input hook on window event: 0X800C."

@marcelblum , @Djiit Yes . I test in Windows 10 and Electron 11.0.3
I get same Result

@lanye74
Copy link

lanye74 commented Dec 5, 2020

Oh it works for 11 as well? That's sweet!
Any time reference for when this will be merged?

@marcelblum
Copy link
Contributor

Just realized why those random keys weren't firing events - it was because the stale examples folder demos I was testing with use the deprecated keypress iohook event listener. And I had copied that code into my "new" electron example and... GIGO! I've now replaced them both with keydown (#266) and all is working 100% now, no more missed key events!! Awesome!

@marcelblum
Copy link
Contributor

And yeah I also tried compiling with an electron 11 (abi 85) target and it totally works:

Untitled

Awesome work by @ykhwong !

@marcelblum
Copy link
Contributor

And I'm an idiot, the only reason for the verbose logging I was complaining about is because the examples use ioHook.start(true) to force debug mode, duh...

@ykhwong ykhwong changed the title Support Electron 9 and 10 Support Electron 9, 10 and 11 Dec 5, 2020
@ericwooley
Copy link

This is exciting!

I really need this for electron 10, if I can help in any way let me know. sign me up for the alpha test, or whatever is needed. I am not familiar enough with the project to help much with the code. But I believe in you guys! 👏

@majidbigdeli
Copy link

This is exciting!

I really need this for electron 10, if I can help in any way let me know. sign me up for the alpha test, or whatever is needed. I am not familiar enough with the project to help much with the code. But I believe in you guys! 👏

ok . you can clone this project and build for your abi eg in electron 11.0.3 is abi is 85

@Djiit
Copy link
Collaborator

Djiit commented Dec 8, 2020

I was able to reproduce everything (node 14, electron 9 and 11) locally. Thanks @ykhwong for this awesome work. I'll merge this and work on a release.

@Djiit Djiit merged commit e51a869 into wilix-team:master Dec 8, 2020
@Djiit
Copy link
Collaborator

Djiit commented Dec 8, 2020

So, build is working, but the prebuilt are now. If anyone wants to help. I'm creating an issue.

@alexxxcs1 alexxxcs1 mentioned this pull request Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants