🪶
Litebot
🤖
A Deno library for interacting with the mouse
Docs · Report Bug · Request Feature
Getting Started
This is an example of how you can get started with Litebot. You can also check out the examples
folder for more documentation on each function.
-
Import Litebot
import * as litebot from "https://deno.land/x/litebot/mod.ts";
-
Using Litebot Sub-Modules
import { getMousePos } from "https://deno.land/x/litebot/mod.ts"; getMousePos(); // { x: number, y: number }
-
Example Scripts
deno run --allow-read --allow-ffi --allow-env --unstable https://deno.land/x/litebot/examples/mouse/mouse.ts
- To view more more examples check out https://deno.land/x/litebot/examples/
- Mouse Related https://deno.land/x/litebot/examples/mouse/
- Keyboard Related https://deno.land/x/litebot/examples/keyboard/
- Macros Related https://deno.land/x/litebot/examples/macros/
-
If you want to upgrade / switch versions then please use the
-r
&-- --nocache
flags when calling deno run or compile.
deno run -r --allow-read --allow-ffi --allow-env --unstable https://deno.land/x/litebot/examples/mouse/mouse.ts
This will pevent the previously cached dll from being used and will fresh install the new dll.
Usage
Mouse Position & Movement
Currently this library will only work for windows machines. Lets demonstrate how to use some common Litebot functions.
import {
getMousePos,
setMousePos,
moveMouse,
mouseUp,
mouseLeft,
mouseDown,
mouseRight,
} from "https://deno.land/x/litebot/mod.ts";
// Get current position of mouse
const { x, y } = getMousePos();
// Setting the mouse position
setMousePos(0, 0);
setMousePos(-20000, 20398); // unsuccessful call results in the mouse being at the endge of the screen on the x and y
// Relative Mouse Movement
setMousePos(500, 500); // => {x: 500, y: 500}
moveMouse(100, -150); // -> {x: 600, y: 650}; // right 100 & down 150
moveMouse(0, 400); // -> {x: 600, y: 250}; // up 400
// Single Axis Relative Movement
mouseUp(20); // moves mouse up the screen by 20px
mouseUp(-20); // moves mouse down the screen by 20px
// Its possible to move by both positive and negative quantities. This simply inverts the direction again.
mouseLeft(100); // moves mouse left on screen by 100px
mouseRight(-23); // moves mouse left on screen by 23px
mouseDown(100); // moves mouse down on screen by 100px
Mouse / Keyboard Clicks
Handling mouse clicks and keyboard presses is also quiet easy with Litebot. The only diference is these operations are done on a seperate thread
. It is vital to await
them to avoid race conditions between clicks and keyboard presses,
import { setMousePos, mouseClick } from "https://deno.land/x/litebot/mod.ts";
// left click at position 50, 100
setMousePos(50, 100);
await mouseClick();
// right click at same position
await mouseClick({ leftClick: false });
// left click at -100, 100
await mouseClick({ x: -100, y: 100, leftClick: true });
// or
await mouseClick({ x: -100, y: 100 });
Deno Flags
- --allow-env
- --allow-read
- --allow-ffi
- --unstable
If you want to clear the cache or upgrade tyhe release please use these flags.
-- --nocache
-r
For more examples, please refer to the Documentation
Roadmap
-
Screen
-
getMonitors
-
getMonitorCount
-
getActiveMonitor
-
setPixelColor ([r, g, b])
-
getPixelColor (x, y)
-
getMouseColor
-
-
Mouse Actions
- Left Click
- Right Click
- Double Click
- Delayed Click
-
Keyboard Actions
- sendKey (keyCode : Litebot.Keycode )
- sendKeys ( message : string )
- keyPress (key : Litebot.Keycode | char )
- keyRelease (key : Litebot.Keycode | char )
-
Macro's
- Macro.startRecordMacro ()
- Macro.endRecordMacro ()
- Macro.playBack ()
- Macro.erase ()
- Macro.saveMacro () : Litebot.Action []
Completed
- Mouse Moving Relative
- getMousePos
- setMousePos
- mouseUp
- mouseLeft
- mouseRight
- mouseDown
- mouseMove (pxX: number, pxY: number) -- move the mouse vertically and horicontaly at same time
See the open issues for a full list of proposed features (and known issues).
Contact
Tyler Laceby: @tylerbadger23 - Twitter
My Channel: JSimplified - YouTube
Deno Repo: https://deno.land/x/litebot/
Project Link: https://github.com/tylerlaceby/litebot