Just as it says in the title. Possible? I don’t think it can be done through javascript alone, to get the pointer position at the time of a keypress event for instance. But I wonder if anyone has any trick on how to do it from within an add-on.
Keeping constant track of mouse movement by setting a mousemove listener is not really an option.
One note about x11 though, x11 is only meant to be used on the main thread. If you want to use it from a ChromeWorker, then you’ll need to use XCB. I did a lot of XCB work so if you need it let me know and I’ll hook you up.
On Mac some functions need to be run from mainthread. I think mouse position via CoreGraphics is thread safe though, pretty sure.
ChromeWorker is definitely the recommend way to run js-ctypes. If you use PromiseWorker then you can make a quick getMostPosition function that returns a promise, really nice and simple - https://developer.mozilla.org/en-US/docs/Web/API/PromiseWorker
Except for the fact that I’ve never used ctypes or any external libs/resources myself, so it’s a lot to learn just to open a panel next to the mouse… My procrastinating alter-ego is screaming in my head “just anchor the thing somewhere” right now.
Dude you’re awesome! But you really don’t need to. I can’t even test it properly across all systems right now. :’( And it’s not urgent at all, just a curiosity I thought up this morning. Tell you what, in a few weeks (well, realistically, months), I’m going to give js-ctypes a go anyway because eventually I’ll have to. This will be a good place to start, so by then if I can ask you for help with it that’d be just awesome.