From 3eabb6e0a0c8d1a230ae5a8f08f9ce4f7dc89a04 Mon Sep 17 00:00:00 2001 From: Robert Soriano Date: Sat, 16 Jul 2022 23:41:07 -0700 Subject: [PATCH] feat: add mouse move function --- main.go | 19 +++++++++++++++++++ src/ffi.ts | 11 +++++++++++ test/index.test.ts | 34 ++++++++++++++++++++++++---------- 3 files changed, 54 insertions(+), 10 deletions(-) diff --git a/main.go b/main.go index 027b2c9..20fbe37 100644 --- a/main.go +++ b/main.go @@ -124,4 +124,23 @@ func GetScaleSize() *C.char { return ch(string(coords)) } +/* +.___ ___. ______ __ __ _______. _______ +| \/ | / __ \ | | | | / || ____| +| \ / | | | | | | | | | | (----`| |__ +| |\/| | | | | | | | | | \ \ | __| +| | | | | `--' | | `--' | .----) | | |____ +|__| |__| \______/ \______/ |_______/ |_______| +*/ + +//export Move +func Move(x, y int) { + robotgo.Move(x, y) +} + +//export DragSmooth +func DragSmooth(x, y int, args *C.char) { + robotgo.DragSmooth(x, y, str(args)) +} + func main() {} // Required but ignored diff --git a/src/ffi.ts b/src/ffi.ts index 3c688a3..477839f 100644 --- a/src/ffi.ts +++ b/src/ffi.ts @@ -24,6 +24,11 @@ const { symbols } = dlopen(`${import.meta.dir}/../release/bunbot.${suffix}`, { args: [], returns: FFIType.ptr }, + // Mouse + Move: { + args: [FFIType.int, FFIType.int], + returns: FFIType.void + }, FreeString: { args: [FFIType.ptr], returns: FFIType.void @@ -53,3 +58,9 @@ export function getScaleSize(): Coords { const ptr = symbols.GetScaleSize() return JSON.parse(toString(ptr)) } + +// Mouse + +export function move(x: number, y: number) { + symbols.Move(x, y) +} diff --git a/test/index.test.ts b/test/index.test.ts index f368886..924425a 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -1,18 +1,32 @@ -import { test, expect } from 'bun:test' -import { getVersion, getMouseColor, getScreenSize, getScaleSize } from '../src' +import { describe, test, expect } from 'bun:test' +import { + getVersion, + getMouseColor, + getScreenSize, + getScaleSize, + move +} from '../src' test('getVersion', () => { expect(getVersion()).toBe("v1.00.0.1189, MT. Baker!") }) -test('getMouseColor', () => { - console.log(getMouseColor()) +describe('Screen functions', () => { + test('getMouseColor', () => { + console.log(getMouseColor()) + }) + + test('getScreenSize', () => { + console.log(getScreenSize()) + }) + + test('getScaleSize', () => { + console.log(getScaleSize()) + }) }) -test('getScreenSize', () => { - console.log(getScreenSize()) -}) - -test('getScaleSize', () => { - console.log(getScaleSize()) +describe('Mouse functions', () => { + test('move', () => { + move(100, 100) + }) })