octalmage / robotjs

Node.js Desktop Automation.

Home Page:http://robotjs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

CxrlosKenobi opened this issue · comments

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

  • RobotJS version: 0.6.0
  • Node.js version: v16.13.2
  • npm version: 8.5.1
  • Operating System: Ubuntu 20.04.4 LTS

This project appears to be unmaintained, see #622