Skip to content

Commit

Permalink
Merge pull request #539 from go-vgo/bitmap-pr
Browse files Browse the repository at this point in the history
Unified name and Update godoc, fixed typo
  • Loading branch information
vcaesar authored Nov 1, 2022
2 parents 4ad733f + 4bf054f commit fc5dac6
Show file tree
Hide file tree
Showing 18 changed files with 108 additions and 76 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Golang
GCC
```

#### For Mac OS X:
#### For MacOS:

Xcode Command Line Tools (And Privacy setting: [#277](https://github.com/go-vgo/robotgo/issues/277) )

Expand Down Expand Up @@ -163,8 +163,8 @@ import (
func main() {
robotgo.MouseSleep = 100

robotgo.ScrollMouse(10, "up")
robotgo.ScrollMouse(20, "right")
robotgo.ScrollDir(10, "up")
robotgo.ScrollDir(20, "right")

robotgo.Scroll(0, -10)
robotgo.Scroll(100, 0)
Expand Down Expand Up @@ -242,7 +242,7 @@ import (
)

func main() {
x, y := robotgo.GetMousePos()
x, y := robotgo.Location()
fmt.Println("pos: ", x, y)

color := robotgo.GetPixelColor(100, 200)
Expand Down Expand Up @@ -455,7 +455,7 @@ func main() {
robotgo.KeyToggle("a", fpid[0])
robotgo.KeyToggle("a", fpid[0], "up")

robotgo.ActivePID(fpid[0])
robotgo.ActivePid(fpid[0])

robotgo.Kill(fpid[0])
}
Expand Down Expand Up @@ -519,9 +519,9 @@ Some discussions and questions, please see [issues/228](https://github.com/go-vg
## Plans
- Refactor some C code to Go (such as x11, windows)
- Better multiscreen support
- Waylad supports
- Wayland support
- Update Window Handle
- Try support Android and IOS
- Try to support Android and IOS

## Contributors

Expand Down
4 changes: 3 additions & 1 deletion README_zh.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Robotgo

## !!! Warning: this page not updated !!!

[![Build Status](https://github.com/go-vgo/robotgo/workflows/Go/badge.svg)](https://github.com/go-vgo/robotgo/commits/master)
[![CircleCI Status](https://circleci.com/gh/go-vgo/robotgo.svg?style=shield)](https://circleci.com/gh/go-vgo/robotgo)
[![Build Status](https://travis-ci.org/go-vgo/robotgo.svg)](https://travis-ci.org/go-vgo/robotgo)
Expand Down Expand Up @@ -67,7 +69,7 @@ xcode-select --install

```
Or the other GCC (But you should compile the "libpng" with yourself.
Or you can removed the bitmap.go )
Or you can removed the bitmap.go.)
```

#### For everything else (Linux 等其他系统):
Expand Down
4 changes: 2 additions & 2 deletions base/pubs.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
return TRUE;
}

HWND GetHwndByPId(DWORD dwProcessId) {
HWND GetHwndByPid(DWORD dwProcessId) {
WNDINFO info = {0};
info.hWnd = NULL;
info.dwPid = dwProcessId;
EnumWindows(EnumWindowsProc, (LPARAM)&info);
// printf("%d\n", info.hWnd);

return info.hWnd;
}
#endif
6 changes: 3 additions & 3 deletions examples/mouse/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func click() {

func get() {
// gets the mouse coordinates
x, y := robotgo.GetMousePos()
x, y := robotgo.Location()
fmt.Println("pos:", x, y)
if x == 456 && y == 586 {
fmt.Println("mouse...", "586")
Expand All @@ -66,8 +66,8 @@ func get() {

func toggleAndScroll() {
// scrolls the mouse either up
robotgo.ScrollMouse(10, "up")
robotgo.ScrollMouse(10, "right")
robotgo.ScrollDir(10, "up")
robotgo.ScrollDir(10, "right")

robotgo.Scroll(100, 10)
robotgo.Scroll(0, -10)
Expand Down
6 changes: 3 additions & 3 deletions examples/window/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func alert() {

func get() {
// get the current process id
pid := robotgo.GetPID()
pid := robotgo.GetPid()
fmt.Println("pid----", pid)

// get current Window Active
Expand Down Expand Up @@ -64,7 +64,7 @@ func findIds() {

fmt.Println("pids...", fpid)
if len(fpid) > 0 {
err = robotgo.ActivePID(fpid[0])
err = robotgo.ActivePid(fpid[0])
if err != nil {
fmt.Println(err)
}
Expand All @@ -87,7 +87,7 @@ func findIds() {
}

func active() {
robotgo.ActivePID(100)
robotgo.ActivePid(100)
// robotgo.Sleep(2)
robotgo.ActiveName("code")
robotgo.Sleep(1)
Expand Down
28 changes: 15 additions & 13 deletions key.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ const (
LightsKbdDown = "lights_kbd_down"
)

// keyNames define MMKeyCode map
// keyNames define a map of key names to MMKeyCode
var keyNames = map[string]C.MMKeyCode{
"backspace": C.K_BACKSPACE,
"delete": C.K_DELETE,
Expand Down Expand Up @@ -441,7 +441,7 @@ func keyToggles(k string, keyArr []string, pid int) error {
*/

// ToInterfaces []string to []interface{}
// ToInterfaces convert []string to []interface{}
func ToInterfaces(fields []string) []interface{} {
res := make([]interface{}, 0, len(fields))
for _, s := range fields {
Expand All @@ -450,7 +450,7 @@ func ToInterfaces(fields []string) []interface{} {
return res
}

// ToStrings []interface{} to []string
// ToStrings convert []interface{} to []string
func ToStrings(fields []interface{}) []string {
res := make([]string, 0, len(fields))
for _, s := range fields {
Expand All @@ -467,19 +467,20 @@ func toErr(str *C.char) error {
return errors.New(gstr)
}

// KeyTap tap the keyboard code;
// KeyTap taps the keyboard code;
//
// See keys:
//
// https://github.com/go-vgo/robotgo/blob/master/docs/keys.md
//
// Examples:
//
// robotgo.KeySleep = 100 // 100 millisecond
// robotgo.KeyTap("a")
// robotgo.KeyTap("i", "alt", "command")
//
// arr := []string{"alt", "command"}
// robotgo.KeyTap("i", arr)
//
func KeyTap(key string, args ...interface{}) error {
var keyArr []string

Expand Down Expand Up @@ -512,17 +513,18 @@ func KeyTap(key string, args ...interface{}) error {
return keyTaps(key, keyArr, pid)
}

// KeyToggle toggle the keyboard, if there not have args default is "down"
// KeyToggle toggles the keyboard, if there not have args default is "down"
//
// See keys:
//
// https://github.com/go-vgo/robotgo/blob/master/docs/keys.md
//
// Examples:
//
// robotgo.KeyToggle("a")
// robotgo.KeyToggle("a", "up")
//
// robotgo.KeyToggle("a", "up", "alt", "cmd")
//
func KeyToggle(key string, args ...interface{}) error {

if len(key) > 0 && unicode.IsUpper([]rune(key)[0]) {
Expand Down Expand Up @@ -633,13 +635,13 @@ func inputUTF(str string) {
C.free(unsafe.Pointer(cstr))
}

// TypeStr send a string, supported UTF-8
// TypeStr send a string (supported UTF-8)
//
// robotgo.TypeStr(string: "The string to send", int: pid, "milli_sleep time", "x11 option")
//
// Examples:
// robotgo.TypeStr("abc@123, Hi galaxy, こんにちは")
//
// robotgo.TypeStr("abc@123, Hi galaxy, こんにちは")
func TypeStr(str string, args ...int) {
var tm, tm1 = 0, 7

Expand Down Expand Up @@ -681,7 +683,7 @@ func TypeStr(str string, args ...int) {
MilliSleep(KeySleep)
}

// PasteStr paste a string, support UTF-8,
// PasteStr paste a string (support UTF-8),
// write the string to clipboard and tap `cmd + v`
func PasteStr(str string) error {
err := clipboard.WriteAll(str)
Expand All @@ -696,23 +698,23 @@ func PasteStr(str string) error {
return KeyTap("v", "control")
}

// TypeStrDelay type string delayed
// TypeStrDelay type string with delayed
func TypeStrDelay(str string, delay int) {
TypeStr(str)
MilliSleep(delay)
}

// Deprecated: use the TypeStr(),
//
// TypeStringDelayed type string delayed, Wno-deprecated
// # 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 set the key and mouse delay
// SetDelay sets the key and mouse delay
func SetDelay(d ...int) {
v := 10
if len(d) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion mouse/mouse_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void clickMouse(MMMouseButton button){
toggleMouse(false, button);
}

/* Special function for sending double clicks, needed for Mac OS X. */
/* Special function for sending double clicks, needed for MacOS. */
void doubleClick(MMMouseButton button){
#if defined(IS_MACOSX)
/* Double click for Mac. */
Expand Down
3 changes: 3 additions & 0 deletions robot_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ func TestGetScreenSize(t *testing.T) {

rect := robotgo.GetScreenRect()
fmt.Println("Get screen rect: ", rect)

x, y = robotgo.Location()
fmt.Println("Get location: ", x, y)
}

func TestGetSysScale(t *testing.T) {
Expand Down
Loading

0 comments on commit fc5dac6

Please sign in to comment.