-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from rubickCenter/revert-5-feature/new
Revert ":recycle: 修改 simulation 实现方式,添加单测."
- Loading branch information
Showing
15 changed files
with
100 additions
and
2,621 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
|
||
### Node ### | ||
# Logs | ||
.idea | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,62 @@ | ||
import { keyboard, Key, mouse, left, right, up, down, straightTo } from "@nut-tree/nut-js"; | ||
import { | ||
Position, | ||
sendKeyboardSimulation as ks, | ||
sendMouseSimulation as ms, | ||
} from "../addon"; | ||
|
||
keyboard.config.autoDelayMs = 10; | ||
mouse.config.autoDelayMs = 10; | ||
export type MouseBtn = | ||
| "Left" | ||
| "Middle" | ||
| "Right" | ||
| "Back" | ||
| "Forward" | ||
|
||
export { keyboard, mouse, Key, left, right, up, down, straightTo} | ||
export interface MoveMoveInput { | ||
type: "relative" | "absolute"; | ||
data: Position; | ||
} | ||
|
||
// example: {+CTRL}a{-CTRL}{+SHIFT}Hello World{-SHIFT} | ||
// 所有可用键 https://github.com/enigo-rs/enigo/blob/master/src/keycodes.rs | ||
export const sendKeyboardSimulation = (cmd: string) => ks(cmd); | ||
|
||
export const mouseScrollX = (len: number) => { | ||
ms({ action: 3, data: { x: len, y: 0 } }); | ||
} | ||
|
||
export const mouseScrollY = (len: number) => { | ||
ms({ action: 4, data: { x: 0, y: len } }); | ||
}; | ||
|
||
export const mouseMove = (input: MoveMoveInput) => { | ||
ms({ action: input.type === "absolute" ? 2 : 1, data: input.data }); | ||
}; | ||
|
||
export const mouseLocaion = () => ms({ action: 0 }) | ||
|
||
const mouseDUC = (btn: MouseBtn, action: 5 | 6 | 7) => { | ||
let button = 0; | ||
switch (btn) { | ||
case "Left": | ||
break; | ||
case "Middle": | ||
button = 1; | ||
break; | ||
case "Right": | ||
button = 2; | ||
break; | ||
case "Back": | ||
button = 3; | ||
break; | ||
case "Forward": | ||
button = 4; | ||
break; | ||
default: | ||
break; | ||
} | ||
ms({ action, button }); | ||
}; | ||
|
||
export const mouseDown = (btn: MouseBtn) => mouseDUC(btn, 6) | ||
export const mouseUp = (btn: MouseBtn) => mouseDUC(btn, 5) | ||
export const mouseClick = (btn: MouseBtn) => mouseDUC(btn, 7) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { existsSync } from "fs"; | ||
import { getSystemApp } from "./src" | ||
|
||
console.time("1") | ||
await getSystemApp((e) => { | ||
if (!existsSync(e.execPath)) { | ||
console.log(e); | ||
} | ||
}) | ||
console.timeEnd("1") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,16 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowSyntheticDefaultImports": true, | ||
"declaration": true, | ||
"downlevelIteration": true, | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"importHelpers": false, | ||
"module": "CommonJS", | ||
"moduleResolution": "node", | ||
"newLine": "LF", | ||
"noEmitHelpers": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"removeComments": true, | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"target": "ES2018", | ||
"inlineSourceMap": true, | ||
"esModuleInterop": true, | ||
"stripInternal": true, | ||
"importsNotUsedAsValues": "remove", | ||
"paths": { | ||
"@node-rs/*": ["./addon"] | ||
}, | ||
"outDir": "dist", | ||
"lib": ["dom", "ES5", "ES2015", "ES2016", "ES2017", "ES2018", "ES2019", "ES2020", "esnext"] | ||
"esModuleInterop": true, | ||
"module": "ESNext", | ||
"moduleResolution": "Node", | ||
"target": "ESNext", | ||
"lib": [ | ||
"ESNext", | ||
"DOM" | ||
] | ||
}, | ||
"include": [ | ||
"./src/**/*", | ||
], | ||
"exclude": ["node_modules", "addon"] | ||
"./src/**/*" | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.