@lysyyds/win32-mouse-keyboard-hook 1.0.10 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,108 @@
1
- Before starting, please configure the development environment: desktop development using C++/Windows 10/11 SDK/Python 3, and then run `npm run build`
1
+ ## What's this for
2
+
3
+ C++ mouse-keyboard-hook for Electron -> Windows
4
+
5
+ supported Electron verion:
6
+
7
+ - "22.3.27", // 最后一个支持 Win7 的版本
8
+ - "23.3.13",
9
+ - "24.8.3",
10
+ - "25.9.0",
11
+ - "26.2.0",
12
+ - "27.3.0",
13
+ - "28.2.0",
14
+ - "29.4.0",
15
+ - "30.5.1",
16
+ - "31.0.0",
17
+
18
+ ## Usage
19
+
20
+ ### install
21
+
22
+ ```
23
+ npm i @lysyyds/win32-mouse-keyboard-hook
24
+
25
+ ```
26
+
27
+ ### use
28
+
29
+ ```typescript
30
+ // import
31
+ const win32KeyboardHook = require("@lysyyds/win32-mouse-keyboard-hook");
32
+ // or
33
+ // import win32KeyboardHook from "@lysyyds/win32-mouse-keyboard-hook";
34
+
35
+ // import types
36
+ import type { Callback } from "@lysyyds/win32-mouse-keyboard-hook";
37
+
38
+ const callback: Callback = (type, eventType, x, y) => {
39
+ const [type, eventType, x, y] = args;
40
+ if (type === "key") {
41
+ // keyboard event
42
+ if (eventType == 1) {
43
+ // keydown
44
+ x; // keycode
45
+ } else if (eventType == 2) {
46
+ // keyup
47
+ x; // keycode
48
+ }
49
+ } else if (type === "mouse") {
50
+ x; // mouse position x
51
+ y; // mouse position y
52
+
53
+ if (eventType == 2) {
54
+ // mouse left button down
55
+ } else if (eventType == 3) {
56
+ // mouse left button up
57
+ } else if (eventType == 4) {
58
+ // mouse right button down
59
+ } else if (eventType == 5) {
60
+ // mouse right button up
61
+ } else if (eventType == 6) {
62
+ // wheel active
63
+ }
64
+ }
65
+ };
66
+
67
+ win32KeyboardHook.start(callback);
68
+ ```
69
+
70
+
71
+ types
72
+ ``` typescript
73
+ declare module "@lysyyds/win32-mouse-keyboard-hook" {
74
+ export type Callback = (
75
+ type: "key" | "mouse",
76
+ eventType: number,
77
+ x: number,
78
+ y: number,
79
+ ) => void;
80
+
81
+ export type CallbackArgs = Parameters<Callback>;
82
+
83
+ export function start(callback: Callback): void;
84
+ export function stop(): void;
85
+
86
+ export enum KeyboardEventType {
87
+ KeyDown = 1,
88
+ KeyUp = 2,
89
+ }
90
+
91
+ export enum MouseEventType {
92
+ Move = 1,
93
+ LeftDown = 2,
94
+ LeftUp = 3,
95
+ RightDown = 4,
96
+ RightUp = 5,
97
+ Wheel = 6,
98
+ }
99
+ }
100
+
101
+ ```
102
+
103
+ ## Build yourself
104
+
105
+ Before starting, please configure the development environment: desktop development using C++/Windows 10/11 SDK/Python 3, and then run `npm run build`
2
106
 
3
107
  ```
4
108
  **********************************************************************
@@ -24,4 +128,4 @@ D:\sourcecode\win32-keyboard-hook>python --version
24
128
  Python 3.14.2
25
129
 
26
130
  D:\sourcecode\win32-keyboard-hook>npm run build
27
- ```
131
+ ```
package/package.json CHANGED
@@ -1,14 +1,18 @@
1
1
  {
2
2
  "name": "@lysyyds/win32-mouse-keyboard-hook",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "C++ mouse-keyboard-hook for NodeJS & Electron",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "scripts": {
8
- "build": "node-gyp rebuild --target=30.0.0 --dist-url=https://electronjs.org/headers",
8
+ "build-all": "node scripts/prebuild.js",
9
9
  "install": "prebuild-install || echo \"skip node build\"",
10
10
  "test": "echo \"Error: no test specified\" && exit 1"
11
11
  },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/meiguiyisenluo/win32-mouse-keyboard-hook.git"
15
+ },
12
16
  "files": [
13
17
  "index.js",
14
18
  "index.d.ts",
@@ -29,11 +33,14 @@
29
33
  "license": "ISC",
30
34
  "dependencies": {
31
35
  "node-addon-api": "^8.5.0",
32
- "prebuild-install": "^7.1.3",
33
- "node-gyp-build": "^4.8.4"
36
+ "node-gyp-build": "^4.8.4",
37
+ "prebuild-install": "^7.1.3"
34
38
  },
35
39
  "devDependencies": {
36
- "node-gyp": "^12.2.0"
40
+ "install": "^0.13.0",
41
+ "node-abi": "^4.26.0",
42
+ "node-gyp": "^12.2.0",
43
+ "npm": "^11.8.0"
37
44
  },
38
45
  "exports": {
39
46
  ".": {