I have tried two methods.
One is to use setImmediate instead of setInterval, but it mainly uses getCursorScreenPoint.
The other is to program with C++, use system functions, expose a TypeScript interface, and package it as a node package for use in your Electron code.