mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-28 13:03:56 +00:00
Update: used NotPid option args and move Deprecated func to v1
This commit is contained in:
parent
f830c8ed13
commit
df1617d894
13
key.go
13
key.go
@ -27,7 +27,6 @@ import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/go-vgo/robotgo/clipboard"
|
||||
"github.com/vcaesar/tt"
|
||||
)
|
||||
|
||||
// Defining a bunch of constants.
|
||||
@ -723,22 +722,14 @@ func PasteStr(str string) error {
|
||||
}
|
||||
|
||||
// TypeStrDelay type string with delayed
|
||||
// And you can use robotgo.KeySleep = 100 to delayed not this function
|
||||
func TypeStrDelay(str string, delay int) {
|
||||
TypeStr(str)
|
||||
MilliSleep(delay)
|
||||
}
|
||||
|
||||
// Deprecated: use the TypeStr(),
|
||||
//
|
||||
// # TypeStringDelayed type string delayed, Wno-deprecated
|
||||
//
|
||||
// This function will be removed in version v1.0.0
|
||||
func TypeStringDelayed(str string, delay int) {
|
||||
tt.Drop("TypeStringDelayed", "TypeStrDelay")
|
||||
TypeStrDelay(str, delay)
|
||||
}
|
||||
|
||||
// SetDelay sets the key and mouse delay
|
||||
// robotgo.SetDelay(100) option the robotgo.KeySleep and robotgo.MouseSleep = d
|
||||
func SetDelay(d ...int) {
|
||||
v := 10
|
||||
if len(d) > 0 {
|
||||
|
103
robotgo.go
103
robotgo.go
@ -331,6 +331,7 @@ func CaptureScreen(args ...int) CBitmap {
|
||||
if NotPid || len(args) > 5 {
|
||||
isPid = 1
|
||||
}
|
||||
|
||||
bit := C.capture_screen(x, y, w, h, C.int32_t(displayId), C.int8_t(isPid))
|
||||
return CBitmap(bit)
|
||||
}
|
||||
@ -444,45 +445,6 @@ func ScaleX() int {
|
||||
return int(C.scaleX())
|
||||
}
|
||||
|
||||
// Deprecated: use the ScaledF(),
|
||||
//
|
||||
// Scale get the screen scale (only windows old), drop
|
||||
func Scale() int {
|
||||
dpi := map[int]int{
|
||||
0: 100,
|
||||
// DPI Scaling Level
|
||||
96: 100,
|
||||
120: 125,
|
||||
144: 150,
|
||||
168: 175,
|
||||
192: 200,
|
||||
216: 225,
|
||||
// Custom DPI
|
||||
240: 250,
|
||||
288: 300,
|
||||
384: 400,
|
||||
480: 500,
|
||||
}
|
||||
|
||||
x := ScaleX()
|
||||
return dpi[x]
|
||||
}
|
||||
|
||||
// Deprecated: use the ScaledF(),
|
||||
//
|
||||
// Scale0 return ScaleX() / 0.96, drop
|
||||
func Scale0() int {
|
||||
return int(float64(ScaleX()) / 0.96)
|
||||
}
|
||||
|
||||
// Deprecated: use the ScaledF(),
|
||||
//
|
||||
// Mul mul the scale, drop
|
||||
func Mul(x int) int {
|
||||
s := Scale()
|
||||
return x * s / 100
|
||||
}
|
||||
|
||||
/*
|
||||
.___ ___. ______ __ __ _______. _______
|
||||
| \/ | / __ \ | | | | / || ____|
|
||||
@ -512,13 +474,6 @@ func CheckMouse(btn string) C.MMMouseButton {
|
||||
return C.LEFT_BUTTON
|
||||
}
|
||||
|
||||
// Deprecated: use the Move(),
|
||||
//
|
||||
// MoveMouse move the mouse
|
||||
func MoveMouse(x, y int) {
|
||||
Move(x, y)
|
||||
}
|
||||
|
||||
// Move move the mouse to (x, y)
|
||||
//
|
||||
// Examples:
|
||||
@ -538,18 +493,6 @@ func Move(x, y int) {
|
||||
MilliSleep(MouseSleep)
|
||||
}
|
||||
|
||||
// Deprecated: use the DragSmooth(),
|
||||
//
|
||||
// DragMouse drag the mouse to (x, y),
|
||||
// It's same with the DragSmooth() now
|
||||
func DragMouse(x, y int, args ...interface{}) {
|
||||
Toggle("left")
|
||||
MilliSleep(50)
|
||||
// Drag(x, y, args...)
|
||||
MoveSmooth(x, y, args...)
|
||||
Toggle("left", "up")
|
||||
}
|
||||
|
||||
// Deprecated: use the DragSmooth(),
|
||||
//
|
||||
// Drag drag the mouse to (x, y),
|
||||
@ -579,14 +522,6 @@ func DragSmooth(x, y int, args ...interface{}) {
|
||||
Toggle("left", "up")
|
||||
}
|
||||
|
||||
// Deprecated: use the MoveSmooth(),
|
||||
//
|
||||
// MoveMouseSmooth move the mouse smooth,
|
||||
// moves mouse to x, y human like, with the mouse button up.
|
||||
func MoveMouseSmooth(x, y int, args ...interface{}) bool {
|
||||
return MoveSmooth(x, y, args...)
|
||||
}
|
||||
|
||||
// MoveSmooth move the mouse smooth,
|
||||
// moves mouse to x, y human like, with the mouse button up.
|
||||
//
|
||||
@ -649,13 +584,6 @@ func MoveSmoothRelative(x, y int, args ...interface{}) {
|
||||
MoveSmooth(mx, my, args...)
|
||||
}
|
||||
|
||||
// Deprecated: use the function Location()
|
||||
//
|
||||
// GetMousePos get the mouse's position return x, y
|
||||
func GetMousePos() (int, int) {
|
||||
return Location()
|
||||
}
|
||||
|
||||
// Location get the mouse location position return x, y
|
||||
func Location() (int, int) {
|
||||
pos := C.location()
|
||||
@ -665,15 +593,6 @@ func Location() (int, int) {
|
||||
return x, y
|
||||
}
|
||||
|
||||
// Deprecated: use the Click(),
|
||||
//
|
||||
// # MouseClick click the mouse
|
||||
//
|
||||
// robotgo.MouseClick(button string, double bool)
|
||||
func MouseClick(args ...interface{}) {
|
||||
Click(args...)
|
||||
}
|
||||
|
||||
// Click click the mouse button
|
||||
//
|
||||
// robotgo.Click(button string, double bool)
|
||||
@ -938,8 +857,8 @@ func MinWindow(pid int, args ...interface{}) {
|
||||
if len(args) > 0 {
|
||||
state = args[0].(bool)
|
||||
}
|
||||
if len(args) > 1 {
|
||||
isPid = args[1].(int)
|
||||
if len(args) > 1 || NotPid {
|
||||
isPid = 1
|
||||
}
|
||||
|
||||
C.min_window(C.uintptr(pid), C.bool(state), C.int8_t(isPid))
|
||||
@ -955,8 +874,8 @@ func MaxWindow(pid int, args ...interface{}) {
|
||||
if len(args) > 0 {
|
||||
state = args[0].(bool)
|
||||
}
|
||||
if len(args) > 1 {
|
||||
isPid = args[1].(int)
|
||||
if len(args) > 1 || NotPid {
|
||||
isPid = 1
|
||||
}
|
||||
|
||||
C.max_window(C.uintptr(pid), C.bool(state), C.int8_t(isPid))
|
||||
@ -973,8 +892,8 @@ func CloseWindow(args ...int) {
|
||||
if len(args) > 0 {
|
||||
pid = args[0]
|
||||
}
|
||||
if len(args) > 1 {
|
||||
isPid = args[1]
|
||||
if len(args) > 1 || NotPid {
|
||||
isPid = 1
|
||||
}
|
||||
|
||||
C.close_window_by_PId(C.uintptr(pid), C.int8_t(isPid))
|
||||
@ -989,8 +908,8 @@ func SetHandle(hwnd int) {
|
||||
// SetHandlePid set the window handle by pid
|
||||
func SetHandlePid(pid int, args ...int) {
|
||||
var isPid int
|
||||
if len(args) > 0 {
|
||||
isPid = args[0]
|
||||
if len(args) > 0 || NotPid {
|
||||
isPid = 1
|
||||
}
|
||||
|
||||
C.set_handle_pid_mData(C.uintptr(pid), C.int8_t(isPid))
|
||||
@ -999,8 +918,8 @@ func SetHandlePid(pid int, args ...int) {
|
||||
// GetHandPid get handle mdata by pid
|
||||
func GetHandPid(pid int, args ...int) C.MData {
|
||||
var isPid int
|
||||
if len(args) > 0 {
|
||||
isPid = args[0]
|
||||
if len(args) > 0 || NotPid {
|
||||
isPid = 1
|
||||
}
|
||||
|
||||
return C.set_handle_pid(C.uintptr(pid), C.int8_t(isPid))
|
||||
|
95
robotgo_fn_v1.go
Normal file
95
robotgo_fn_v1.go
Normal file
@ -0,0 +1,95 @@
|
||||
package robotgo
|
||||
|
||||
import "github.com/vcaesar/tt"
|
||||
|
||||
// Deprecated: use the Move(),
|
||||
//
|
||||
// MoveMouse move the mouse
|
||||
func MoveMouse(x, y int) {
|
||||
Move(x, y)
|
||||
}
|
||||
|
||||
// Deprecated: use the DragSmooth(),
|
||||
//
|
||||
// DragMouse drag the mouse to (x, y),
|
||||
// It's same with the DragSmooth() now
|
||||
func DragMouse(x, y int, args ...interface{}) {
|
||||
Toggle("left")
|
||||
MilliSleep(50)
|
||||
// Drag(x, y, args...)
|
||||
MoveSmooth(x, y, args...)
|
||||
Toggle("left", "up")
|
||||
}
|
||||
|
||||
// Deprecated: use the MoveSmooth(),
|
||||
//
|
||||
// MoveMouseSmooth move the mouse smooth,
|
||||
// moves mouse to x, y human like, with the mouse button up.
|
||||
func MoveMouseSmooth(x, y int, args ...interface{}) bool {
|
||||
return MoveSmooth(x, y, args...)
|
||||
}
|
||||
|
||||
// Deprecated: use the function Location()
|
||||
//
|
||||
// GetMousePos get the mouse's position return x, y
|
||||
func GetMousePos() (int, int) {
|
||||
return Location()
|
||||
}
|
||||
|
||||
// Deprecated: use the Click(),
|
||||
//
|
||||
// # MouseClick click the mouse
|
||||
//
|
||||
// robotgo.MouseClick(button string, double bool)
|
||||
func MouseClick(args ...interface{}) {
|
||||
Click(args...)
|
||||
}
|
||||
|
||||
// Deprecated: use the TypeStr(),
|
||||
//
|
||||
// # TypeStringDelayed type string delayed, Wno-deprecated
|
||||
//
|
||||
// This function will be removed in version v1.0.0
|
||||
func TypeStringDelayed(str string, delay int) {
|
||||
tt.Drop("TypeStringDelayed", "TypeStrDelay")
|
||||
TypeStrDelay(str, delay)
|
||||
}
|
||||
|
||||
// Deprecated: use the ScaledF(),
|
||||
//
|
||||
// Scale get the screen scale (only windows old), drop
|
||||
func Scale() int {
|
||||
dpi := map[int]int{
|
||||
0: 100,
|
||||
// DPI Scaling Level
|
||||
96: 100,
|
||||
120: 125,
|
||||
144: 150,
|
||||
168: 175,
|
||||
192: 200,
|
||||
216: 225,
|
||||
// Custom DPI
|
||||
240: 250,
|
||||
288: 300,
|
||||
384: 400,
|
||||
480: 500,
|
||||
}
|
||||
|
||||
x := ScaleX()
|
||||
return dpi[x]
|
||||
}
|
||||
|
||||
// Deprecated: use the ScaledF(),
|
||||
//
|
||||
// Scale0 return ScaleX() / 0.96, drop
|
||||
func Scale0() int {
|
||||
return int(float64(ScaleX()) / 0.96)
|
||||
}
|
||||
|
||||
// Deprecated: use the ScaledF(),
|
||||
//
|
||||
// Mul mul the scale, drop
|
||||
func Mul(x int) int {
|
||||
s := Scale()
|
||||
return x * s / 100
|
||||
}
|
@ -16,8 +16,8 @@ package robotgo
|
||||
// GetBounds get the window bounds
|
||||
func GetBounds(pid int, args ...int) (int, int, int, int) {
|
||||
var isPid int
|
||||
if len(args) > 0 {
|
||||
isPid = args[0]
|
||||
if len(args) > 0 || NotPid {
|
||||
isPid = 1
|
||||
}
|
||||
|
||||
return internalGetBounds(pid, isPid)
|
||||
@ -26,8 +26,8 @@ func GetBounds(pid int, args ...int) (int, int, int, int) {
|
||||
// GetClient get the window client bounds
|
||||
func GetClient(pid int, args ...int) (int, int, int, int) {
|
||||
var isPid int
|
||||
if len(args) > 0 {
|
||||
isPid = args[0]
|
||||
if len(args) > 0 || NotPid {
|
||||
isPid = 1
|
||||
}
|
||||
|
||||
return internalGetClient(pid, isPid)
|
||||
@ -36,8 +36,8 @@ func GetClient(pid int, args ...int) (int, int, int, int) {
|
||||
// internalGetTitle get the window title
|
||||
func internalGetTitle(pid int, args ...int) string {
|
||||
var isPid int
|
||||
if len(args) > 0 {
|
||||
isPid = args[0]
|
||||
if len(args) > 0 || NotPid {
|
||||
isPid = 1
|
||||
}
|
||||
gtitle := cgetTitle(pid, isPid)
|
||||
|
||||
@ -54,8 +54,8 @@ func internalGetTitle(pid int, args ...int) string {
|
||||
// robotgo.ActivePid(ids[0])
|
||||
func ActivePid(pid int, args ...int) error {
|
||||
var isPid int
|
||||
if len(args) > 0 {
|
||||
isPid = args[0]
|
||||
if len(args) > 0 || NotPid {
|
||||
isPid = 1
|
||||
}
|
||||
|
||||
internalActive(pid, isPid)
|
||||
|
@ -29,8 +29,8 @@ var xu *xgbutil.XUtil
|
||||
// GetBounds get the window bounds
|
||||
func GetBounds(pid int, args ...int) (int, int, int, int) {
|
||||
var isPid int
|
||||
if len(args) > 0 {
|
||||
isPid = args[0]
|
||||
if len(args) > 0 || NotPid {
|
||||
isPid = 1
|
||||
return internalGetBounds(pid, isPid)
|
||||
}
|
||||
|
||||
@ -46,8 +46,8 @@ func GetBounds(pid int, args ...int) (int, int, int, int) {
|
||||
// GetClient get the window client bounds
|
||||
func GetClient(pid int, args ...int) (int, int, int, int) {
|
||||
var isPid int
|
||||
if len(args) > 0 {
|
||||
isPid = args[0]
|
||||
if len(args) > 0 || NotPid {
|
||||
isPid = 1
|
||||
return internalGetClient(pid, isPid)
|
||||
}
|
||||
|
||||
@ -63,8 +63,8 @@ func GetClient(pid int, args ...int) (int, int, int, int) {
|
||||
// internalGetTitle get the window title
|
||||
func internalGetTitle(pid int, args ...int) string {
|
||||
var isPid int
|
||||
if len(args) > 0 {
|
||||
isPid = args[0]
|
||||
if len(args) > 0 || NotPid {
|
||||
isPid = 1
|
||||
return cgetTitle(pid, isPid)
|
||||
}
|
||||
|
||||
@ -81,8 +81,8 @@ func internalGetTitle(pid int, args ...int) string {
|
||||
// If args[0] > 0 on the unix platform via a xid to active
|
||||
func ActivePidC(pid int, args ...int) error {
|
||||
var isPid int
|
||||
if len(args) > 0 {
|
||||
isPid = args[0]
|
||||
if len(args) > 0 || NotPid {
|
||||
isPid = 1
|
||||
internalActive(pid, isPid)
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user