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

Does not work with macOS Mojave 10.14 #8

Open
scarlac opened this issue Oct 30, 2018 · 5 comments
Open

Does not work with macOS Mojave 10.14 #8

scarlac opened this issue Oct 30, 2018 · 5 comments

Comments

@scarlac
Copy link

scarlac commented Oct 30, 2018

With latest master (247d83e, tag: v1.3.1), running the tests + moving the mouse fails to produce any output unlike prior version of macOS 10.13.

I've been unable to find a workaround, other than manually asking for accessibility permissions which according to Apple shouldn't be necessary for "listenOnly" taps.

Output when running test and moving mouse:

11:29:14 ~/jobs/osx-mouse ⚡️ yarn test
yarn run v1.10.1
$ node test/parallel-destroy && node test/parallel-unref && node test/sequence-destroy && node test/sequence-unref
destroy_1
destroy_2
unref_1
unref_2
destroy_1
destroy_2
unref_1
unref_2
✨  Done in 8.45s.

Output when giving full access via "accessibility" (to Terminal.app which I'm running the command through):

11:30:36 ~/jobs/osx-mouse ⚡️ yarn test
yarn run v1.10.1
$ node test/parallel-destroy && node test/parallel-unref && node test/sequence-destroy && node test/sequence-unref
move_2 710.3046875 539.0625
move_2 718.83984375 264.81640625
move_2 720.46484375 265.546875
move_2 722.171875 269.61328125
move_2 724.04296875 273.67578125
(...)
@paulius005
Copy link

Adding accessibility permissions to the app using it remedies the problem. @kapetan is this to be expected?

@poiru
Copy link

poiru commented Jan 14, 2019

I switched to using the Cocoa/NSEvent monitor API (as opposed to CGEventTap) in my fork. That works fine without accessibility permissions, but it has one difference. When the app window is focused, move events will be received for the entire screen. When the app window is not focused, move events will only be received when the cursor is over one of the app windows. Other events will not be received when the app window is not focused.

@kapetan Would you be interested in a PR that adds the NSEvent implementation as an alternative? Maybe we could have something like require('osx-mouse')({ mode: 'nsevent' | 'cgeventtap' }). Or perhaps the module could even check for accessibility permissions and fall back to the NSEvent API on Mojave.

poiru added a commit to poiru/osx-mouse-cocoa that referenced this issue Jan 15, 2019
@poiru
Copy link

poiru commented Jan 15, 2019

Here is my fork as a npm module: https://www.npmjs.com/package/osx-mouse-cocoa

@FengyunSky
Copy link

FengyunSky commented Jan 16, 2019

Calling CGEventTapCreate will cause the system to be stuck, but will not fail. ^_^||

@kapetan
Copy link
Owner

kapetan commented Jan 21, 2019

Nice work @poiru. Maybe it makes sense to merge it into this module, I'll have a look when I find the time. But for now I'm happy with it being a separate module.

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

No branches or pull requests

5 participants