octalmage / robotjs

Node.js Desktop Automation.
http://robotjs.io
MIT License
12.26k stars 937 forks source link

Uncaught TypeError: Cannot set properties of undefined (setting 'capture') by using React/Electron environment #708

Open CxrlosKenobi opened 2 years ago

CxrlosKenobi commented 2 years ago

The general context that I developed a bot that automate the mouse and clicks of the desktop, by using React and Electron for build the App.

BUT, I've been stuck with the next error in Console:

Uncaught TypeError: Cannot set properties of undefined (setting 'capture')
    at Object../node_modules/robotjs/index.js (index.js:23:1)
    at Object.options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:61:1)
    at Module../src/bot/index.js (index.js:1:1)
    at Module.options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:61:1)
    at Module../src/components/Checkboxs.js (index.js:21:1)
    at Module.options.factory (react refresh:6:1)

I used the same sin/cosine example from docs in a js file, then importing the functions into a React component with: import { drawSine } from '../bot/index'; Where my expected behavior for the Electron app is, to use the sin example applied to the component such that when a button is triggered, the function should be executed and the mouse moved by the imported RobotJS script. As in this reference:

import { drawSine } from '../bot/index';

function Checkbox(){ 
  function handleSubmit() {
    drawSine();
  }

  return (
    <button onClick={handleSubmit}>
      Start
    </button>
  );
};

Even tho I rebuilt my project using the Electron docs/wiki provided by RobotJS; Me and my code still stuck by that bug Uncaught TypeError.

Would someone leave a message of help/hope for this stressed dev?

Environment

jugglinmike commented 2 years ago

This project appears to be unmaintained, see https://github.com/octalmage/robotjs/pull/622