Skip to content

Commit 5a26126

Browse files
committed
chore: remove robotjs, use nut-js instead
version:1.0.13
1 parent caea206 commit 5a26126

File tree

3 files changed

+813
-28
lines changed

3 files changed

+813
-28
lines changed
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { ipcMain } from "electron/main";
2-
import robotJs from "@hurdlegroup/robotjs";
2+
import { Button, mouse } from "@nut-tree-fork/nut-js";
3+
4+
const buttonMapper = {
5+
left: Button.LEFT,
6+
right: Button.RIGHT,
7+
middle: Button.MIDDLE,
8+
};
39

410
export const mouseClickHandler = (_ipcMain: typeof ipcMain) => {
511
_ipcMain.handle(
@@ -9,8 +15,11 @@ export const mouseClickHandler = (_ipcMain: typeof ipcMain) => {
915
actionType?: "singleClick" | "doubleClick",
1016
clickButton?: "left" | "right" | "middle"
1117
) => {
12-
const clickPattern = actionType === "doubleClick";
13-
return robotJs.mouseClick(clickButton || "left", clickPattern);
18+
if (actionType === "singleClick") {
19+
mouse.click(buttonMapper[clickButton || "left"]);
20+
return
21+
}
22+
mouse.doubleClick(buttonMapper[clickButton || "left"]);
1423
}
1524
);
1625
};

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mouse-automator",
33
"private": true,
4-
"version": "1.0.12",
4+
"version": "1.0.13",
55
"type": "module",
66
"author": "Terry Chan",
77
"description": "Mouse Automator is a lightweight, user-friendly desktop application designed to automate mouse clicks with ease. Whether you're gaming, testing software, or handling repetitive tasks, Mouse Automator has you covered!",
@@ -20,7 +20,7 @@
2020
"@fortawesome/fontawesome-svg-core": "^6.5.2",
2121
"@fortawesome/free-solid-svg-icons": "^6.5.2",
2222
"@fortawesome/react-fontawesome": "^0.2.2",
23-
"@hurdlegroup/robotjs": "^0.12.2",
23+
"@nut-tree-fork/nut-js": "^4.2.2",
2424
"@tanstack/react-query": "^5.45.1",
2525
"@trufflesuite/ps-list": "^0.0.3",
2626
"electron-store": "^9.0.0",

0 commit comments

Comments
 (0)