Skip to content

Commit

Permalink
feat: add mouse move function
Browse files Browse the repository at this point in the history
  • Loading branch information
wobsoriano committed Jul 17, 2022
1 parent 1f9bf2a commit 3eabb6e
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 10 deletions.
19 changes: 19 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions src/ffi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
34 changes: 24 additions & 10 deletions test/index.test.ts
Original file line number Diff line number Diff line change
@@ -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)
})
})

0 comments on commit 3eabb6e

Please sign in to comment.