Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions bindings/go/dll_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,19 @@ var (
procBindWindow *windows.LazyProc
procBindWindowEx *windows.LazyProc
procUnBindWindow *windows.LazyProc
procLockInput *windows.LazyProc
procGetBindWindow *windows.LazyProc
procIsBind *windows.LazyProc
procGetCursorPos *windows.LazyProc
procGetCursorShape *windows.LazyProc
procMoveR *windows.LazyProc
procMoveTo *windows.LazyProc
procMoveToEx *windows.LazyProc
procMoveToSmooth *windows.LazyProc
procMoveToExSmooth *windows.LazyProc
procMovePath *windows.LazyProc
procDragPath *windows.LazyProc
procSetMouseTrajectory *windows.LazyProc
procLeftClick *windows.LazyProc
procLeftDoubleClick *windows.LazyProc
procLeftDown *windows.LazyProc
Expand Down Expand Up @@ -299,13 +305,19 @@ func bindProcs() {
procBindWindow = dll.NewProc("OpBindWindow")
procBindWindowEx = dll.NewProc("OpBindWindowEx")
procUnBindWindow = dll.NewProc("OpUnBindWindow")
procLockInput = dll.NewProc("OpLockInput")
procGetBindWindow = dll.NewProc("OpGetBindWindow")
procIsBind = dll.NewProc("OpIsBind")
procGetCursorPos = dll.NewProc("OpGetCursorPos")
procGetCursorShape = dll.NewProc("OpGetCursorShape")
procMoveR = dll.NewProc("OpMoveR")
procMoveTo = dll.NewProc("OpMoveTo")
procMoveToEx = dll.NewProc("OpMoveToEx")
procMoveToSmooth = dll.NewProc("OpMoveToSmooth")
procMoveToExSmooth = dll.NewProc("OpMoveToExSmooth")
procMovePath = dll.NewProc("OpMovePath")
procDragPath = dll.NewProc("OpDragPath")
procSetMouseTrajectory = dll.NewProc("OpSetMouseTrajectory")
procLeftClick = dll.NewProc("OpLeftClick")
procLeftDoubleClick = dll.NewProc("OpLeftDoubleClick")
procLeftDown = dll.NewProc("OpLeftDown")
Expand Down
4 changes: 2 additions & 2 deletions bindings/go/image_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (o *Op) FindMultiColorEx(x1, y1, x2, y2 int, firstColor, offsetColor string

func (o *Op) FindPic(x1, y1, x2, y2 int, files, deltaColor string, sim float64, dir int) (int, int, int) {
if !o.valid() {
return 0, 0, 0
return -1, -1, -1
}

var x, y int32
Expand Down Expand Up @@ -88,7 +88,7 @@ func (o *Op) FindPicExS(x1, y1, x2, y2 int, files, deltaColor string, sim float6

func (o *Op) FindColorBlock(x1, y1, x2, y2 int, color string, sim float64, count, height, width int) (int, int, int) {
if !o.valid() {
return 0, 0, 0
return 0, -1, -1
}

var x, y int32
Expand Down
62 changes: 62 additions & 0 deletions bindings/go/input_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,59 @@ func (o *Op) MoveToEx(x, y, w, h int) string {
return wcharString(ret)
}

func (o *Op) MoveToSmooth(x, y, duration int) int {
if !o.valid() {
return 0
}

ret, _, _ := procMoveToSmooth.Call(o.handle, uintptr(x), uintptr(y), uintptr(duration))
return int(ret)
}

func (o *Op) MoveToExSmooth(x, y, w, h, duration int) string {
if !o.valid() {
return ""
}

ret, _, _ := procMoveToExSmooth.Call(o.handle, uintptr(x), uintptr(y), uintptr(w), uintptr(h), uintptr(duration))
return wcharString(ret)
}

func (o *Op) MovePath(path string, duration int) int {
if !o.valid() {
return 0
}

ret, _, _ := procMovePath.Call(o.handle, strArg(path), uintptr(duration))
return int(ret)
}

func (o *Op) DragPath(path string, duration int) int {
if !o.valid() {
return 0
}

ret, _, _ := procDragPath.Call(o.handle, strArg(path), uintptr(duration))
return int(ret)
}

func (o *Op) SetMouseTrajectory(mode, minDuration, maxDuration, jitter, startDelay, endDelay int) int {
if !o.valid() {
return 0
}

ret, _, _ := procSetMouseTrajectory.Call(
o.handle,
uintptr(mode),
uintptr(minDuration),
uintptr(maxDuration),
uintptr(jitter),
uintptr(startDelay),
uintptr(endDelay),
)
return int(ret)
}

func (o *Op) LeftClick() int {
return o.callNoArgs(procLeftClick)
}
Expand Down Expand Up @@ -163,6 +216,15 @@ func (o *Op) SetMouseDelay(typ string, delay int) int {
return int(ret)
}

func (o *Op) LockInput(lock int) int {
if !o.valid() {
return 0
}

ret, _, _ := procLockInput.Call(o.handle, uintptr(lock))
return int(ret)
}

func (o *Op) GetKeyState(vkCode int) int {
if !o.valid() {
return 0
Expand Down
4 changes: 2 additions & 2 deletions bindings/go/ocr_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ func (o *Op) GetDict(idx, fontIndex int) string {
return wcharString(ret)
}

func (o *Op) SetMemDict(idx int, data string, size int) int {
func (o *Op) SetMemDict(idx int, data []byte) int {
if !o.valid() {
return 0
}

ret, _, _ := procSetMemDict.Call(o.handle, uintptr(idx), strArg(data), uintptr(size))
ret, _, _ := procSetMemDict.Call(o.handle, uintptr(idx), bytesPtr(data), uintptr(len(data)))
return int(ret)
}

Expand Down
8 changes: 7 additions & 1 deletion bindings/python/op/_ffi.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,19 @@ def _bind(dll: ctypes.WinDLL) -> ctypes.WinDLL:
("OpBindWindow", c_int, [op_handle, intptr_t, c_wchar_p, c_wchar_p, c_wchar_p, c_int]),
("OpBindWindowEx", c_int, [op_handle, intptr_t, intptr_t, c_wchar_p, c_wchar_p, c_wchar_p, c_int]),
("OpUnBindWindow", c_int, [op_handle]),
("OpLockInput", c_int, [op_handle, c_int]),
("OpGetBindWindow", intptr_t, [op_handle]),
("OpIsBind", c_int, [op_handle]),
("OpGetCursorPos", c_int, [op_handle, c_int_p, c_int_p]),
("OpGetCursorShape", c_wchar_p, [op_handle]),
("OpMoveR", c_int, [op_handle, c_int, c_int]),
("OpMoveTo", c_int, [op_handle, c_int, c_int]),
("OpMoveToEx", c_wchar_p, [op_handle, c_int, c_int, c_int, c_int]),
("OpMoveToSmooth", c_int, [op_handle, c_int, c_int, c_int]),
("OpMoveToExSmooth", c_wchar_p, [op_handle, c_int, c_int, c_int, c_int, c_int]),
("OpMovePath", c_int, [op_handle, c_wchar_p, c_int]),
("OpDragPath", c_int, [op_handle, c_wchar_p, c_int]),
("OpSetMouseTrajectory", c_int, [op_handle, c_int, c_int, c_int, c_int, c_int, c_int]),
("OpLeftClick", c_int, [op_handle]),
("OpLeftDoubleClick", c_int, [op_handle]),
("OpLeftDown", c_int, [op_handle]),
Expand Down Expand Up @@ -281,7 +287,7 @@ def _bind(dll: ctypes.WinDLL) -> ctypes.WinDLL:
("OpYoloDetectFromFile", c_wchar_p, [op_handle, c_wchar_p, c_double, c_double]),
("OpSetDict", c_int, [op_handle, c_int, c_wchar_p]),
("OpGetDict", c_wchar_p, [op_handle, c_int, c_int]),
("OpSetMemDict", c_int, [op_handle, c_int, c_wchar_p, c_int]),
("OpSetMemDict", c_int, [op_handle, c_int, c_void_p, c_int]),
("OpUseDict", c_int, [op_handle, c_int]),
("OpAddDict", c_int, [op_handle, c_int, c_wchar_p]),
("OpSaveDict", c_int, [op_handle, c_int, c_wchar_p]),
Expand Down
52 changes: 49 additions & 3 deletions bindings/python/op/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import ctypes
import locale
from enum import Enum
from pathlib import Path
from typing import Any
Expand Down Expand Up @@ -402,6 +403,9 @@ def bind_window_ex(
def unbind_window(self) -> bool:
return self._call_ok("OpUnBindWindow")

def lock_input(self, lock: int) -> bool:
return self._call_ok("OpLockInput", int(lock))

def get_bind_window(self) -> int:
return self._call_intptr("OpGetBindWindow")

Expand All @@ -424,6 +428,37 @@ def move_to(self, x: int, y: int) -> bool:
def move_to_ex(self, x: int, y: int, width: int, height: int) -> str:
return self._call_string("OpMoveToEx", int(x), int(y), int(width), int(height))

def move_to_smooth(self, x: int, y: int, duration: int) -> bool:
return self._call_ok("OpMoveToSmooth", int(x), int(y), int(duration))

def move_to_ex_smooth(self, x: int, y: int, width: int, height: int, duration: int) -> str:
return self._call_string("OpMoveToExSmooth", int(x), int(y), int(width), int(height), int(duration))

def move_path(self, path: str, duration: int) -> bool:
return self._call_ok("OpMovePath", str(path), int(duration))

def drag_path(self, path: str, duration: int) -> bool:
return self._call_ok("OpDragPath", str(path), int(duration))

def set_mouse_trajectory(
self,
mode: int,
min_duration: int,
max_duration: int,
jitter: int,
start_delay: int,
end_delay: int,
) -> bool:
return self._call_ok(
"OpSetMouseTrajectory",
int(mode),
int(min_duration),
int(max_duration),
int(jitter),
int(start_delay),
int(end_delay),
)

def left_click(self) -> bool:
return self._call_ok("OpLeftClick")

Expand Down Expand Up @@ -1090,9 +1125,20 @@ def set_dict(self, idx: int, file_name: str | Path) -> bool:
def get_dict(self, idx: int, font_index: int) -> str:
return self._call_string("OpGetDict", int(idx), int(font_index))

def set_mem_dict(self, idx: int, data: str, size: int | None = None) -> bool:
data_size = len(data) if size is None else int(size)
return self._call_ok("OpSetMemDict", int(idx), data, data_size)
def set_mem_dict(self, idx: int, data: str | bytes | bytearray | memoryview | int, size: int | None = None) -> bool:
self._check_open()
if isinstance(data, int):
if size is None:
raise ValueError("size is required when data is a pointer")
ptr = ctypes.c_void_p(data)
data_size = int(size)
else:
raw = data.encode(locale.getpreferredencoding(False)) if isinstance(data, str) else bytes(data)
buffer = ctypes.create_string_buffer(raw)
ptr = ctypes.cast(buffer, ctypes.c_void_p)
data_size = len(raw) if size is None else int(size)
ok = self._dll.OpSetMemDict(self._handle, int(idx), ptr, data_size)
return self._ok(ok, "OpSetMemDict")

def use_dict(self, idx: int) -> bool:
return self._call_ok("OpUseDict", int(idx))
Expand Down
93 changes: 0 additions & 93 deletions doc/open_issues_scan.md

This file was deleted.

Loading
Loading