# Technical Documentation: go-vgo/robotgo

> ℹ️ **Provenance:** Multi-Tier Ingestion · [CodeWiki Reference](https://codewiki.google/github.com/go-vgo/robotgo)

### Overview (`README.md`)

# Robotgo

<p align="center">
  <img src="docs/robotgo-logo.svg" width="560" alt="RobotGo logo — a robot with a mouse pointer" />
</p>



[](https://github.com/go-vgo/robotgo/commits/master)
[](https://circleci.com/gh/go-vgo/robotgo)
[](https://codecov.io/gh/go-vgo/robotgo)
[](https://github.com/go-vgo/robotgo/actions/workflows/lint.yml)
[](https://pkg.go.dev/github.com/go-vgo/robotgo?tab=doc)
[](https://github.com/go-vgo/robotgo/releases/latest)
<a href="https://discord.gg/npPb3NzE4A"><img src="https://img.shields.io/discord/1484658282777018551.svg?logo=discord&logoColor=white&label=Discord&color=5865F2" alt="Join the Discord chat at https://discord.gg/npPb3NzE4A"></a>

English | [简体中文](langs/README.zh.md) | [繁體中文](langs/README.zht.md) | [日本語](langs/README.ja.md) | [한국어](langs/README.ko.md) | [Français](langs/README.fr.md) | [Deutsch](langs/README.de.md) | [Español](langs/README.es.md) | [Русский](langs/README.ru.md) | [Português](langs/README.pt.md)

> Golang Desktop Automation, auto test and AI Computer Use. <br>
> Control the mouse, keyboard, read the screen, process, Window Handle, image and bitmap and global event listener.

RobotGo supports Mac, Windows, and Linux; and robotgo supports arm64 and x86-amd64.

I build [Codg](https://github.com/vcaesar/codg) now, Easy code and work AI agent system: auto, asynchronous, concurrency, efficiently and High accuracy

<p align="center">
<a href="https://github.com/vcaesar/codg" rel="nofollow">

<img width="800" alt="Codg Demo" src="https://github.com/vcaesar/codg/raw/main/demo/26-04-1.png" />
</a>
</p>

[RobotGo-Pro](https://github.com/vcaesar/robotgo-pro) get the JavaScript, Python, Lua and others version, tech supports, new features and newest robotgo version ("no open-source version now").

## Contents

- [Docs](#docs)
- [Donate](#Donate)
- [Binding](#binding)
- [Requirements](#requirements)
- [Cgo-free Builds](#cgo-free-builds)
- [Installation](#installation)
- [Update](#update)
- [Examples](#examples)
- [Type Conversion and keys](https://github.com/go-vgo/robotgo/blob/master/docs/keys.md)
- [Cross-Compiling](https://github.com/go-vgo/robotgo/blob/master/docs/install.md#crosscompiling)
- [Authors](#authors)
- [Plans](#plans)
- [License](#license)

## Docs

- [GoDoc](https://godoc.org/github.com/go-vgo/robotgo) <br>
- [API Docs](https://github.com/go-vgo/robotgo/blob/master/docs/doc.md) (Deprecated, no updated)

## Donate

Donors and sponsors, or others, Contact: vzvway@gmail.com

## Binding

[ADB](https://github.com/vcaesar/adb), packaging android adb and ios wda, robotgo compatible API.

## Requirements

**Go 1.26+** (see [go.mod](go.mod)) and one backend:

- **Default (Cgo):** `CGO_ENABLED=1`, a C compiler and the platform libraries below.
- **Pure Go (tested):** no C toolchain; see [Cgo-free Builds](#cgo-free-builds).

Both need the [feature-specific dependencies](#feature-specific-dependencies)
for the features you use.

### Default Cgo setup

#### macOS

Go and the Xcode Command Line Tools (Clang):

```sh
brew install go
xcode-select --install
```

**Permissions (Cgo and pure Go):** in **System Settings > Privacy & Security**,
grant the app or terminal **Accessibility** (input) and **Screen Recording**
(capture).

#### Windows

```powershell
winget install GoLang.Go
```

Plus **one** C toolchain. [LLVM-MinGW](https://github.com/mstorsjo/llvm-mingw):

```powershell
winget install MartinStorsjo.LLVM-MinGW.UCRT
$env:CC = "clang"
```

Or [MinGW-w64 (WinLibs)](https://winlibs.com/):

```powershell
winget install BrechtSanders.WinLibs.POSIX.UCRT
$env:CC = "gcc"
```

The toolchain's `bin` (e.g. `C:\mingw64\bin`) must be on `PATH` and match
`GOARCH`. Any other Cgo-compatible compiler, such as a manual
[MinGW-w64](https://sourceforge.net/projects/mingw-w64/files) install, also works.

[Bitmap](https://github.com/vcaesar/bitmap) ships libpng for MinGW-w64 only;
with another toolchain, build libpng yourself.

#### Linux (X11)

Build: GCC, libc headers, X11/XTest headers. Runtime: an X server with XTEST
and `DISPLAY` set. For native Wayland, see [Cgo-free Builds](#cgo-free-builds).

**Ubuntu / Debian:**

```sh
# Go (Snap if the distro package is too old)
sudo snap install go --classic
# or: sudo apt install golang

# Core (Cgo): compiler, libc, X11, XTest
sudo apt install gcc libc6-dev libx11-dev xorg-dev libxtst-dev

# Clipboard (X11)
sudo apt install xsel xclip

# Bitmap: libpng
sudo apt install libpng++-dev

# GoHook: XCB, XKB
sudo apt install xcb libxcb-xkb-dev x11-xkb-utils libx11-xcb-dev libxkbcommon-x11-dev libxkbcommon-dev
```

**Fedora:**

```sh
# Core (Cgo): compiler, libc, X11, XTest
sudo dnf install gcc glibc-devel libX11-devel libXtst-devel

# Clipboard (X11)
sudo dnf install xsel xclip

# Bitmap: libpng
sudo dnf install libpng-devel

# GoHook: XKB (Fedora < 34: xorg-x11-xkb-utils-devel instead of xkbcomp-devel)
sudo dnf install libxkbcommon-devel libxkbcommon-x11-devel xkbcomp-devel
```

### Feature-specific dependencies

Needed on top of the core setup, only for the features you use:

- **Linux clipboard (Cgo and pure Go):** `xclip` or `xsel` on X11;
  `wl-clipboard` on Wayland:

  ```sh
  sudo apt install wl-clipboard   # Ubuntu / Debian
  sudo dnf install wl-clipboard   # Fedora
  ```

- **[Bitmap](https://github.com/vcaesar/bitmap):** libpng headers.
- **[GoHook](https://github.com/robotn/gohook):** XCB/XKB headers on Linux.

Bitmap and GoHook are separate Cgo packages; a pure-Go RobotGo backend does not
remove their C requirements.

## Cgo-free Builds

**Tested pure-Go backends** build and cross-compile with `CGO_ENABLED=0`
(no GCC, MinGW, Xcode or X11 headers). Same import path and API; a **build tag**
selects the backend — `CGO_ENABLED=0` alone selects nothing.

| Target `GOOS` | Build tag | Package             | Runtime requirements                                             |
| ------------- | --------- | ------------------- | ---------------------------------------------------------------- |
| `windows`     | `win`     | [win](win/)         | Win32 only, no extra runtime                                     |
| `darwin`      | `mac`     | [darwin](darwin/)   | System frameworks and [privacy permissions](#macos)              |
| `linux`       | `x11`     | [x11](x11/)         | X server with XTEST, `DISPLAY` set                               |
| `linux`       | `wayland` | [wayland](wayland/) | wlroots compositor, see [Wayland](#wayland)                      |
| `linux`       | `libei`   | [libei](libei/)     | RemoteDesktop portal (GNOME/KDE), see [libei](#libei-gnome--kde) |

**`purego`** is a shortcut: `mac` on macOS, `win` on Windows, `wayland` on
Linux. Add `x11` or `libei` to override on Linux (`-tags "purego,x11"`).

Use **one backend tag** matching `GOOS`; combinations such as `x11,libei` fail
to compile (`purego` plus one Linux override is the only exception).

### Build commands

```sh
# Current OS
CGO_ENABLED=0 go build -tags purego .

# Cross-compile
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -tags win .
CGO_ENABLED=0 GOOS=darwin  GOARCH=arm64 go build -tags mac .
CGO_ENABLED=0 GOOS=linux   GOARCH=amd64 go build -tags x11 .
CGO_ENABLED=0 GOOS=linux   GOARCH=amd64 go build -tags wayland .
CGO_ENABLED=0 GOOS=linux   GOARCH=amd64 go build -tags libei .
```

PowerShell: `$env:CGO_ENABLED = "0"; go build -tags purego .`

Build the module root (`.`) or your own package, not `./...`: `examples/` and
some subpackages need Cgo-only APIs.

### Limitations

The runtime requirements above still apply. Cgo-only APIs such as
`CaptureScreen` / `FreeBitmap` do not exist; use `CaptureImg`. Unsupported
operations return `ErrNotSupported` (or an empty result).

- **`mac`:** window management (`GetTitle`, `GetBounds`, `ActivePid`,
  `ActiveName`, `MinWindow`, `MaxWindow`, `CloseWindow`) uses Accessibility
  and needs the Accessibility permission; `MaxWindow` toggles native full
  screen and `GetClient` equals `GetBounds`.
- **`wayland`, `libei`:** Wayland has no protocol for the global cursor
  position. `Location()` reads the real cursor from Hyprland (IPC socket) and
  KDE Plasma (KWin script over D-Bus) when that query succeeds; `wayland` also
  needs every output to share one scale ratio (differently scaled or rotated
  outputs fall back). Otherwise, and elsewhere (GNOME, Sway, other wlroots
  compositors), it returns the last position injected by RobotGo, not the
  physical cursor. Clipboard needs `wl-clipboard`.

#### Wayland

A wlroots compositor (Sway, Hyprland, Wayfire, ...) with `WAYLAND_DISPLAY` and
`XDG_RUNTIME_DIR` set, exposing:

| Feature           | Protocol global                    |
| ----------------- | ---------------------------------- |
| Mouse control     | `zwlr_virtual_pointer_manager_v1`  |
| Keyboard control  | `zwp_virtual_keyboard_manager_v1`  |
| Screen capture    | `zwlr_screencopy_manager_v1`       |
| Window management | `zwlr_foreign_toplevel_manager_v1` |

GNOME and KDE do not provide these protocols; use `libei` there.

#### libei (GNOME / KDE)

Input goes through the `xdg-desktop-portal` **RemoteDesktop** D-Bus interface:
needs a session bus, `xdg-desktop-portal` and a backend implementing it
(`xdg-desktop-portal-gnome`, `-kde` or `-wlr`). The first run shows a consent
dialog; the restore token is cached under `$XDG_STATE_HOME/robotgo`.

Absolute motion uses a linked ScreenCast stream (default); set
`libei.LinkScreenCast = false` for relative motion only. Screen capture and
window management report `ErrNotSupported`.

## Installation

```sh
go get github.com/go-vgo/robotgo
```

```go
import "github.com/go-vgo/robotgo"
```

`png.h: No such file or directory` with Bitmap: see its libpng requirements and
[issues/47](https://github.com/go-vgo/robotgo/issues/47).

## Update

```sh
go get -u github.com/go-vgo/robotgo
```

Note go1.10.x C file compilation cache problem, [golang #24355](https://github.com/golang/go/issues/24355).
`go mod vendor` problem, [golang #26366](https://github.com/golang/go/issues/26366).

## [Examples](https://github.com/go-vgo/robotgo/blob/master/examples)

#### [Mouse](https://github.com/go-vgo/robotgo/blob/master/examples/mouse/main.go)

```
/* Detailed source-code truncated for AI context efficiency. */
```

#### [Keyboard](https://github.com/go-vgo/robotgo/blob/master/examples/key/main.go)

```Go
package main

import (
  "errors"
  "fmt"

  "github.com/go-vgo/robotgo"
)

func main() {
  robotgo.Type("Hello World")
  robotgo.Type("だんしゃり", 0, 1)
  // robotgo.Type("テストする")

  robotgo.Type("Hi, Seattle space needle, Golden gate bridge, One world trade center.")
  robotgo.Type("Hi galaxy, hi stars, hi MT.Rainier, hi sea. こんにちは世界.")
  robotgo.Sleep(1)

  // ustr := uint32(robotgo.CharCodeAt("Test", 0))
  // robotgo.UnicodeType(ustr)

  robotgo.KeySleep = 100
  robotgo.KeyTap("enter")
  // robotgo.Type("en")
  robotgo.KeyTap("i", "alt", "cmd")

  arr := []string{"alt", "cmd"}
  robotgo.KeyTap("i", arr)

  robotgo.MilliSleep(100)
  robotgo.KeyToggle("a")
  robotgo.KeyToggle("a", "up")

  robotgo.WriteAll("Test")
  text, err := robotgo.ReadAll()
  if err == nil {
    fmt.Println(text)
  }

  // Unknown key names return an error instead of pressing a wrong key
  if err := robotgo.KeyTap("notakey"); err != nil {
    fmt.Println("robotgo.KeyTap error:", err)
  }

  // TypeStr returns the first typing error, Type only returns the count
  if err := robotgo.TypeStr("Hello, 世界"); err != nil {
    fmt.Println("robotgo.TypeStr error:", err)
  }

  // Hold a modifier, then always release it and check both errors
  if err := robotgo.KeyDown("shift"); err == nil {
    err = errors.Join(robotgo.KeyTap("a"), robotgo.KeyUp("shift"))
    if err != nil {
      fmt.Println("shift + a error:", err)
    }
  }
}
```

#### [Screen](https://github.com/go-vgo/robotgo/blob/master/examples/screen/main.go)

```Go
package main

import (
  "fmt"
  "strconv"

  "github.com/go-vgo/robotgo"
  "github.com/vcaesar/imgo"
)

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

  color := robotgo.GetPixelColor(100, 200)
  fmt.Println("color---- ", color)

  sx, sy := robotgo.GetScreenSize()
  fmt.Println("get screen size: ", sx, sy)

  bit := robotgo.CaptureScreen(10, 10, 30, 30)
  defer robotgo.FreeBitmap(bit)

  img := robotgo.ToImage(bit)
  imgo.Save("test.png", img)

  num := robotgo.DisplaysNum()
  for i := 0; i < num; i++ {
    robotgo.DisplayID = i
    img1, _ := robotgo.CaptureImg()
    path1 := "save_" + strconv.Itoa(i)
    robotgo.Save(img1, path1+".png")
    robotgo.SaveJpeg(img1, path1+".jpeg", 50)

    img2, _ := robotgo.CaptureImg(10, 10, 20, 20)
    robotgo.Save(img2, "test_"+strconv.Itoa(i)+".png")

    x, y, w, h := robotgo.GetDisplayBounds(i)
    img3, err := robotgo.CaptureImg(x, y, w, h)
    fmt.Println("Capture error: ", err)
    robotgo.Save(img3, path1+"_1.png")
  }
}
```

#### [Bitmap](https://github.com/vcaesar/bitmap/blob/main/examples/main.go)

```Go
package main

import (
  "fmt"

  "github.com/go-vgo/robotgo"
  "github.com/vcaesar/bitmap"
)

func main() {
  bit := robotgo.CaptureScreen(10, 20, 30, 40)
  // use `defer robotgo.FreeBitmap(bit)` to free the bitmap
  defer robotgo.FreeBitmap(bit)

  fmt.Println("bitmap...", bit)
  img := robotgo.ToImage(bit)
  // robotgo.SavePng(img, "test_1.png")
  robotgo.Save(img, "test_1.png")

  bit2 := robotgo.ToCBitmap(robotgo.ImgToBitmap(img))
  fx, fy := bitmap.Find(bit2)
  fmt.Println("FindBitmap------ ", fx, fy)
  robotgo.Move(fx, fy)

  arr := bitmap.FindAll(bit2)
  fmt.Println("Find all bitmap: ", arr)

  fx, fy = bitmap.Find(bit)
  fmt.Println("FindBitmap------ ", fx, fy)

  bitmap.Save(bit, "test.png")
}
```

#### [OpenCV](https://github.com/vcaesar/gcv)

```Go
package main

import (
  "fmt"
  "math/rand"

  "github.com/go-vgo/robotgo"
  "github.com/vcaesar/gcv"
  "github.com/vcaesar/bitmap"
)

func main() {
  opencv()
}

func opencv() {
  name := "test.png"
  name1 := "test_001.png"
  robotgo.SaveCapture(name1, 10, 10, 30, 30)
  robotgo.SaveCapture(name)

  fmt.Print("gcv find image: ")
  fmt.Println(gcv.FindImgFile(name1, name))
  fmt.Println(gcv.FindAllImgFile(name1, name))

  bit := bitmap.Open(name1)
  defer robotgo.FreeBitmap(bit)
  fmt.Print("find bitmap: ")
  fmt.Println(bitmap.Find(bit))

  // bit0 := robotgo.CaptureScreen()
  // img := robotgo.ToImage(bit0)
  // bit1 := robotgo.CaptureScreen(10, 10, 30, 30)
  // img1 := robotgo.ToImage(bit1)
  // defer robotgo.FreeBitmapArr(bit0, bit1)
  img, _ := robotgo.CaptureImg()
  img1, _ := robotgo.CaptureImg(10, 10, 30, 30)

  fmt.Print("gcv find image: ")
  fmt.Println(gcv.FindImg(img1, img))
  fmt.Println()

  res := gcv.FindAllImg(img1, img)
  fmt.Println(res[0].TopLeft.Y, res[0].Rects.TopLeft.X, res)
  x, y := res[0].TopLeft.X, res[0].TopLeft.Y
  robotgo.Move(x, y-rand.Intn(5))
  robotgo.MilliSleep(100)
  robotgo.Click()

  res = gcv.FindAll(img1, img) // use find template and sift
  fmt.Println("find all: ", res)
  res1 := gcv.Find(img1, img)
  fmt.Println("find: ", res1)

  img2, _, _ := robotgo.DecodeImg("test_001.png")
  x, y = gcv.FindX(img2, img)
  fmt.Println(x, y)
}
```

#### [Event](https://github.com/robotn/gohook/blob/master/examples/main.go)

```Go
package main

import (
  "fmt"

  // "github.com/go-vgo/robotgo"
  hook "github.com/robotn/gohook"
)

func main() {
  add()
  low()
  event()
}

func add() {
  fmt.Println("--- Please press ctrl + shift + q to stop hook ---")
  hook.Register(hook.KeyDown, []string{"q", "ctrl", "shift"}, func(e hook.Event) {
    fmt.Println("ctrl-shift-q")
    hook.End()
  })

  fmt.Println("--- Please press w---")
  hook.Register(hook.KeyDown, []string{"w"}, func(e hook.Event) {
    fmt.Println("w")
  })

  s := hook.Start()
  <-hook.Process(s)
}

func low() {
	evChan := hook.Start()
	defer hook.End()

	for ev := range evChan {
		fmt.Println("hook: ", ev)
	}
}

func event() {
  ok := hook.AddEvents("q", "ctrl", "shift")
  if ok {
    fmt.Println("add events...")
  }

  keve := hook.AddEvent("k")
  if keve {
    fmt.Println("you press... ", "k")
  }

  mleft := hook.AddEvent("mleft")
  if mleft {
    fmt.Println("you press... ", "mouse left button")
  }
}
```

#### [Window](https://github.com/go-vgo/robotgo/blob/master/examples/window/main.go)

```Go
package main

import (
  "fmt"

  "github.com/go-vgo/robotgo"
)

func main() {
  fpid, err := robotgo.FindIds("Google")
  if err == nil {
    fmt.Println("pids... ", fpid)

    if len(fpid) > 0 {
      robotgo.Type("Hi galaxy!", fpid[0])
      robotgo.KeyTap("a", fpid[0], "cmd")

      robotgo.KeyToggle("a", fpid[0])
      robotgo.KeyToggle("a", fpid[0], "up")

      robotgo.ActivePid(fpid[0])

      robotgo.Kill(fpid[0])
    }
  }

  robotgo.ActiveName("chrome")

  isExist, err := robotgo.PidExists(100)
  if err == nil && isExist {
    fmt.Println("pid exists is", isExist)

    robotgo.Kill(100)
  }

  abool := robotgo.Alert("test", "robotgo")
  if abool {
 	  fmt.Println("ok@@@ ", "ok")
  }

  title := robotgo.GetTitle()
  fmt.Println("title@@@ ", title)
}
```

## Authors

- [The author is Evans](https://github.com/vcaesar)
- [Maintainers](https://github.com/orgs/go-vgo/people)

## Plans

- Better multiscreen support
- Update Window Handle

## Contributors

- See [contributors page](https://github.com/go-vgo/robotgo/graphs/contributors) for full list of contributors.
- See [Contribution Guidelines](https://github.com/go-vgo/robotgo/blob/master/CONTRIBUTING.md).

## License

Robotgo is primarily distributed under the terms of "the Apache License (Version 2.0)", with portions covered by various BSD-like licenses.

See [LICENSE-APACHE](http://www.apache.org/licenses/LICENSE-2.0), [LICENSE](https://github.com/go-vgo/robotgo/blob/master/LICENSE).

---

### Overview (`clipboard/README.md`)

This directory based on [clipboard](https://github.com/atotto/clipboard).

[](https://travis-ci.org/atotto/clipboard)
[](http://godoc.org/github.com/atotto/clipboard)


# Clipboard for Go

Provide copying and pasting to the Clipboard for Go.



Build:

    $ go get github.com/atotto/clipboard

Platforms:

* OSX
* Windows 7 (probably work on other Windows)
* Linux, Unix, the first available tool is used:
  * Wayland: `wl-clipboard` (`wl-copy` / `wl-paste`), when `WAYLAND_DISPLAY` is set
  * X11: `xclip` or `xsel`
  * Android Termux: `termux-clipboard-get` / `termux-clipboard-set` (Termux:API add-on)
  * WSL: the Windows clipboard via `clip.exe` / `powershell.exe`
  * tmux: the tmux paste buffer, when running inside tmux (`TMUX` is set)
* Plan 9 (`/dev/snarf`)

`clipboard.Primary = true` selects the primary selection on Wayland and X11,
other tools fall back to the clipboard.


Document: 

* http://godoc.org/github.com/atotto/clipboard

Notes:

* Text string only
* UTF-8 text encoding only (no conversion)

TODO:

* Clipboard watcher(?)

## Commands:

paste shell command:

    $ go get github.com/atotto/clipboard/cmd/gopaste
    $ # example:
    $ gopaste > document.txt

copy shell command:

    $ go get github.com/atotto/clipboard/cmd/gocopy
    $ # example:
    $ cat document.txt | gocopy

---

### Overview (`docs/README.md`)

# Docs

Documents are not necessarily updated synchronously, slower than godoc, please see examples and godoc.

---

### Overview (`examples/README.md`)

# Robotgo examples

## Install:
```
go get -u github.com/go-vgo/robotgo  
```

## [Examples:](https://github.com/go-vgo/robotgo/blob/master/examples)

#### [Mouse](https://github.com/go-vgo/robotgo/blob/master/examples/mouse/main.go)

```Go
package main

import (
	"github.com/go-vgo/robotgo"
)

func main() {
  // robotgo.ScrollMouse(10, "up")
  robotgo.Scroll(0, 10)
  robotgo.MouseClick("left", true)
  robotgo.MoveSmooth(100, 200, 1.0, 100.0)
} 
``` 

#### [Keyboard](https://github.com/go-vgo/robotgo/blob/master/examples/key/main.go)

```Go
package main

import (
  "fmt"

  "github.com/go-vgo/robotgo"
)

func main() {
  robotgo.TypeStr("Hello World")
  // robotgo.TypeStr("だんしゃり")
  robotgo.TypeStr("だんしゃり")
  // ustr := uint32(robotgo.CharCodeAt("だんしゃり", 0))
  // robotgo.UnicodeType(ustr)

  robotgo.KeyTap("enter")
  robotgo.TypeStr("en")
  robotgo.KeyTap("i", "alt", "command")
  arr := []string{"alt", "command"}
  robotgo.KeyTap("i", arr)

  robotgo.WriteAll("Test")
  text, err := robotgo.ReadAll()
  if err == nil {
    fmt.Println(text)
  }
} 
```

#### [Screen](https://github.com/go-vgo/robotgo/blob/master/examples/screen/main.go)

```Go
package main

import (
	"fmt"

	"github.com/go-vgo/robotgo"
)

func main() {
  x, y := robotgo.Location()
  fmt.Println("pos:", x, y)
  color := robotgo.GetPixelColor(100, 200)
  fmt.Println("color----", color)
} 
```

#### [Bitmap](https://github.com/go-vgo/robotgo/blob/master/examples/bitmap/main.go)

```Go
package main

import (
	"fmt"

	"github.com/go-vgo/robotgo"
)

func main() {
  bitmap := robotgo.CaptureScreen(10, 20, 30, 40)
  // use `defer robotgo.FreeBitmap(bit)` to free the bitmap
  defer robotgo.FreeBitmap(bitmap)
  fmt.Println("...", bitmap)

  fx, fy := robotgo.FindBitmap(bitmap)
  fmt.Println("FindBitmap------", fx, fy)

  robotgo.SaveBitmap(bitmap, "test.png")
} 
```

#### [Event](https://github.com/go-vgo/robotgo/blob/master/examples/event/main.go)

```Go
package main

import (
	"fmt"

	"github.com/go-vgo/robotgo"
)

func main() {
  keve := robotgo.AddEvent("k")
  if keve {
    fmt.Println("you press...", "k")
  }

  mleft := robotgo.AddEvent("mleft")
  if mleft {
    fmt.Println("you press...", "mouse left button")
  }
} 
```

#### [Window](https://github.com/go-vgo/robotgo/blob/master/examples/window/main.go)

```Go
package main

import (
	"fmt"

	"github.com/go-vgo/robotgo"
)

func main() {
  fpid, err := robotgo.FindIds("Google")
  if err == nil {
    fmt.Println("pids...", fpid)

    if len(fpid) > 0 {
      robotgo.ActivePID(fpid[0])

      robotgo.Kill(fpid[0])
    }
  }

  robotgo.ActiveName("chrome")

  isExist, err := robotgo.PidExists(100)
  if err == nil && isExist {
    fmt.Println("pid exists is", isExist)

    robotgo.Kill(100)
  }

  abool := robotgo.ShowAlert("test", "robotgo")
  if abool == 0 {
 	  fmt.Println("ok@@@", "ok")
  }

  title := robotgo.GetTitle()
  fmt.Println("title@@@", title)
} 
```

---

### CHANGELOG (`docs/CHANGELOG.md`)

# CHANGELOG


## Unreleased

### Fixed

- [FIX] libei backend: `Move`/`MoveSmooth` were no-ops and `Location` always returned (0, 0) under `-tags libei` (#783). The RemoteDesktop session now links a ScreenCast monitor stream so `NotifyPointerMotionAbsolute` works, `Move` falls back to relative motion when no stream is available, `MoveSmooth` targets an absolute position, `Location` reports the last injected position, and `GetScreenSize`/`GetScreenRect` return the stream geometry. Added `libei.LinkScreenCast` to opt out of the stream.
- [FIX] libei backend: `Location` is now a pure query — it no longer opens a RemoteDesktop session (polling it re-prompted the consent dialog whenever the session was denied or closed) and keeps reporting the last injected position after the portal closes the session (#783).
- [FIX] Cgo Linux: `num_equal` used `XK_equal` (main-row `=`) instead of `XK_KP_Equal`; `right_shift` is accepted as a modifier name by the Cgo and every pure-Go backend.
- [FIX] Cgo: `MoveSmooth`/`DragSmooth` could stop 1px short of the target (the loop exited once the remaining distance was ≤ 1, so `Location()` right after `MoveSmooth(100, 100)` returned `(101, 100)`); the loop now runs until the pointer is on the target. `robotgo_test.go` is untagged and runs the Move → Location / key / clipboard / capture checks against the Cgo and every pure-Go backend (skipping cleanly when headless); Cgo-only bitmap APIs moved to `robot_cgo_test.go`. Added fake-pointer Move/Location tests for the wayland backend.
- [FIX] Cgo: `GetPixelColor` segfaulted and `ToImage(CaptureScreen())` panicked when the screen could not be grabbed (macOS without the Screen Recording permission); they now return black / an empty image. `KeyTap("no_such_key")` returns an error instead of pressing keycode 0.
- [ADD] Pure-Go backends: `SysScale`/`ScaleF`/`Scaled` are wired for every backend (`go test robot_info_test.go` failed to build under `-tags purego`). macOS reports the Retina backing scale, Windows the DPI scale, X11 the physical DPI or `Xft.dpi` / 96 (like the Cgo backend), Wayland the `wl_output.scale` factor of the selected output; libei reports 1 (the portal only exposes logical geometry). Wayland/X11 `GetScaleSize` multiply by the scale like the Cgo backend.
- [FIX] wayland backend: `Location` returns the last injected position instead of a (0, 0) stub.
- [FIX] wayland backend: serialize all go-wayland context access (event dispatch vs. request/proxy creation raced on the unsynchronized object table); `CaptureImg` no longer hangs forever when the connection dies (5s timeout), handles XBGR/ABGR shm formats and the `y_invert` flag; the virtual keyboard now sends the `modifiers` request so shift/ctrl/alt combos work and uses a sealed memfd keymap with the full evdev keycode set (F13-F24, media keys, ...); `Scroll` sends `axis_source` + `axis_discrete`; `Move` maps onto the whole output layout; `MinWindow`/`MaxWindow` act on the active toplevel; closed toplevel handles are destroyed; malformed toplevel events can no longer panic the dispatch goroutine.
- [FIX] libei backend: `Move` without a ScreenCast stream parks the pointer in the corner first instead of being a no-op; points in monitor gaps are clamped; `Type` maps `\n`/`\t`/`\b`/Esc to function keysyms; `KeyTap("A")` implies shift; sessions closed by the portal are re-established; `GetScaleSize(displayId)` honours the display.
- [FIX] darwin (purego) backend: events are created from a HID-system-state source like the Cgo backend; punctuation, shifted symbols (`!`, `{`, ...) and numpad keys resolve; `ScaleF`/`GetScaleSize` report the Retina backing scale; `GetScreenRect(displayId)` returns that display's bounds.
- [FIX] win (pure-Go) backend: key events carry the hardware scan code (raw-input consumers ignored them); numpad and media keys resolve; `ScaleF`/`GetScaleSize` report the DPI scale; `GetScreenRect` follows the Cgo backend's virtual-screen rule.
- [FIX] All pure-Go backends: `Scroll`/`ScrollDir` use the same sign convention as the Cgo backend (positive y = up, positive x = left); the darwin/win/wayland/libei ports previously inverted it.
- [NEW] Cgo and every pure-Go backend: `Move`, `Drag`, `DragSmooth`, `MoveClick`, `MoveRelative`, `MoveSmoothRelative`, `MovesClick`, `Scroll`, `ScrollDir`, `ScrollSmooth`, `ScrollRelative`, `UnicodeType`, `TypeStr`, `TypeDelay` and `TypeStrDelay` now return `error` (previously silent no-ops on failure). `ScrollDir` rejects an unknown or non-string direction instead of doing nothing / panicking; `DragSmooth` always releases the button even when the move fails (and rejects wrong-typed args instead of panicking with the button held); `Type` keeps returning the typed count and stops at the first character that fails. `MoveSmoothRelative`/`MovesClick` return the exported `ErrSmoothMove`.
- [FIX] Cgo `Type`/`UnicodeType`: runes above the BMP (emoji) are sent as a UTF-16 surrogate pair on macOS/Windows instead of being truncated to 16 bits; on Linux `ToUC` spells them as Xlib `U1F600` so `XStringToKeysym` resolves them, and `input_utf` reports an unknown keysym / missing keyboard mapping / rejected XTEST event instead of returning success. Windows: typing into a pid whose window is not found returns `ERROR_INVALID_WINDOW_HANDLE` (previously posted to the caller's own queue and "succeeded"); `NotPid` is honoured by `Type`; an input rejected by UIPI/secure desktop is reported as such instead of `winapi error #-1`. macOS: no longer `CFRelease(NULL)` when the event source can not be created.
- [FIX] win (pure-Go) backend: after a partial `KeyTap`/`KeyToggle` press failure only the keys that were actually pressed are released, so keys held by the user are not keyed up.

## RobotGo v0.100.0, MT. Baker; Enhancement bitmap and image, add arm support...

### Add

- [NEW] add more image function support
- [NEW] add ImgToBitmap(), ToImg(), FindEveryBitmap(), FindEveryColor(), Svae(), Read(), SaveJpeg() and other function support

- [NEW] add func ToImage: convert C.MMBitmapRef to standard image.Image
- [NEW] add ToImage examples code
- [NEW] add more image function and update go mod

- [NEW] add find every color function
- [NEW] add free and find all point function
- [NEW] update find bitmap and color

- [NEW] add byte to image function
- [NEW] add more image convert function

- [NEW] add mac os M1 support
- [NEW] add windows arm support

- [NEW] add more key toggle and press function

- [NEW] add ToRGBA() function support
- [NEW] add ImgToBitmap and RGBAToBitmap support
- [NEW] Update and move image function to img.go

- [NEW] add more img to bitmap examples code and Update file name

### Update

- [NEW] Update README.md and CHANGELOG.md
- [NEW] add macOS to .travis.yml
- [NEW] update go mod pkg

- [NEW] Update hook examples link to newest
- [NEW] update dockerfile and appveyor to go1.14.4

- [NEW] Update README.md, add more examples
- [NEW] move hook and event to gohook
- [NEW] move cbitmap and bitmap-bytes to bitmap dir

- [NEW] update some name
- [NEW] update dockerfile and appveyor.yml

- [NEW] update clipboard code
- [NEW] update hook code and more API

- [NEW] optimize code and update version
- [NEW] add paste string err return and optimize code
- [NEW] update go.yml and travis.yml to go1.15
- [NEW] Update Ubuntu apt-get to apt

- [NEW] update go version and key code
- [NEW] update test code and go mod
- [NEW] Update README.md and test code

- [NEW] update parameter name and version
- [NEW] update dockerfile and appveyor.yml
- [NEW] update error return and print

- [NEW] update ShowAlert optimize return code
- [NEW] add more test and update go mod

- [NEW] compatible with 32-bit platforms
- [NEW] add more bitmap examples

- [NEW] update point structure to public

- [NEW] add more examples
- [NEW] update examples and version
- [NEW] Update clipboard example code

- [NEW] Update README.md Section ####Other to windows (#348) …
- [NEW] Update png.h path
- [NEW] Update go mod
- [NEW] Update circle.yml and travis.yml

- [NEW] Remove unless example code and update circle.yml
- [NEW] Removed drop api example code and Update README.md

- [NEW] Update go mod and xx.yml
- [NEW] Update README.md and example

- [NEW] add more bitmap examples code
- [NEW] Update go mod and Update README.md
- [NEW] gofmt to 1.17 build tag
- [NEW] Update bitmap examples code

- [NEW] Update version and keycode
- [NEW] Update docs remove drop API


### Fixed

- [FIX] Update go mod and fixed #290
- [FIX] Update gohook to v0.30.2 fixed bug
- [FIX] Fixed Mouse buttons reversed type
- [FIX] Fixed returns "Invalid key code specified." if specified character is not v… … add keyCodeForCharFallBack

- [FIX] This fixes the disappearing backslash issue #351
- [FIX] Export ToUC function and update test code
- [FIX] Fixes #258: char* arrays in C not being copied correctly
- [FIX] Fixed Linux TypeStr() function double quote

- [FIX] update free bitmap fixed #333
- [FIX] update gops to v0.20.0 fixed bug and other mod pkg
- [FIX] update gohook fixed warning



## RobotGo v0.90.0, MT. Rainier

### Add

add gohook modern and concurrent API
add new gohook examples, thks for cauefcr

Support for multiple screens
add getMousePos() multiple screens support
add move smooth multiple screens support

add all platform system scale support
add get screen size test code

add screen and bitmap multiple screens support
add int32_t types support

update keycode type use uint16 with gohook, not type convert
add ToBitmapBytes func (#204)

gohook: sched_yield support for non-POSIX windows gcc

add gops test code support
add Process() function test code
add more gops test code

add more win32 function export

add get mouse color function

add uint32 to Chex function support

add key_Toggles() c function
add keyTap and keyToggle "...string" parameters support, Fixed #209

add robotgo simple test code

add Is64Bit() c and go function

add process FindPath() function

add keycode "delete" support and fixed "\\" error
add more keycode support, "up, down, left, right"...

export hook keycode and add godoc

use robotn fork xgb and update go mod

add hook example to robotgo examples

update gohook and tt mod file

add more and update test code

add drag smooth function support and examples

add ShowAlert() test support

update keypress rand sleep [reduce] and update code style, update c delay default value to 0

add mouse toggle return and add more test

add SetDelay function code and update other code

add scaled function code

add go opencv file

add readme.md file

add move mouse and move smooth relative code

add move mouse and move smooth relative examples

add more test code and update go tt mod

add more bitmap test code

add SaveImg function code

add drop function hint print support

add more key test code
add more test code
add paste string test code
add xvfb run codecov test

add keycode test support

add FindPath example code

add KeyTap() args[2] delay support

add find bitmap nil args support

add find color nil args support

add drag and move mouse multiple screens support

add drag mouse test code

Use CGDisplayBounds not CGDisplayPixelsWide, optimize get mac display size …

Update TypeStr function, add type delay and speed support

update PasteStr function code return error

### Update

Update robot info test code and Add go.yml test support

use while not for match special key map
remove unless x11 special key and sort

update go mod pkg
update mod vendor
remove vendor and update .gitignore

update and fmt config.yml, add Linux go test support
update Linux CI support x11 test

move hook to hook.go

update appveyor and test code
update version and code style

update move mouse smooth test code

update clipboard code and add test code

update test code and add codecov support

update show alert test code

update keycode.go

update window examples code

update test code remove windows alert test

move gops code to ps.go

update version

update unix get title type

gofmt go code and update code style

add ToBitmapBytes examples code

update example code, fixed golint warning

update bitmap example code

Update CHANGELOG.md

update code style

update godoc

update keytap code and code style

update Bitmap struct delete fuzzy api

update key examples code

add bitmap from string clear api

update go mod vendor
update go mod pkg not proxy

update bitmap example code

update test code fixed appveyor CI

update test code fixed equal error

update hook godoc

update event example code

update godoc and code style

update key example code

Update example README.md

update and tidy go mod

update code remove duplicate code and update godoc

update xgb getXid log

update GetBounds x11 error log

update cgo code and version

update TypeString function code [Drop]

update key example code

Update TypeStr function, optimize x11 type string

Update TypeStrDelay function, remove unused code

update code fixed x11 type sleep

Update key example code

use gops to simplify code
update key examples code

update bitmap examples code

update colorpicker and findcolor example code

update bitmap example code

update robotgo test code, add more test

Update README.md

rename type names make clearer

update types.h code and fixed bug

remove unused code fixed x11 build error

update robot info test code and appveyor

Update README.md, Add more CI badge

update gohook pkg and robot info test code

Update linux upper code, add more special key support

Create go.yml
Update go.yml
add more test and update go.yml
Update dockerfile to go1.13.5

update dockerfile and appveyor.yml
Update dockerfile and appveyor.yml to go1.14.3

remove Travis go1.11.x
update appveyor and dockerfile to go1.13.1
update dockerfile, go.yml and appveyor.yml to go1.14

update travis.yml to go1.14.x and remove go1.13.x
Update and fmt appveyor.ymlu
update dockerfile and appveyor to go1.12.5

update appveyor and dockerfile to go1.12.6

add CI go1.13 support
update config.yml
update and fmt travis.yml
Update Travis remove go1.12.x

Update issue and pull request template

### Fix

Update to utf-code function Fixed #189

Update x11 keypress upper code Fixed #243

type conversion needed in addMouse (#201)

update hook, Fixed #202 fatal error: concurrent map writes

add key Kind Fixed #203

optimize get title code, Fixed #165 and typo

Fixed gohook#3 mouse is_drag error on x11

Fixed #213 AddEvents() can't listen correctly multiple times

update clipboard error hand Fixed #212

Update go.mod fixing issue "invalid pseudo-version: does not match version …

update keyboard example code, #238

update go mod file Fixed #239

update gops and other mod files fixed bug


## RobotGo v0.80.0, Sierra Nevada

# Sierra Nevada

### Add

- [NEW] Add asynchronous event support
- [NEW] Add multiple keypress event listener support
- [NEW] Add hook start and end func
- [NEW] Add AddEvents, AddMouse, AddMousePos hook function
- [NEW] Add mul() scale func and optimize code
- [NEW] Refactor AddEvent() func and add keycode.go, update example
- [NEW] Add mouse map keycode
- [NEW] Add android null file
- [NEW] Add AddEvent "center" support
- [NEW] Update README.md, Add binding link

 <br/>

- [NEW] Format README.md and docs markdown
- [NEW] Update bitmap_save return code
- [NEW] Optimize code not defer and remove useless code
- [NEW] Update code style and godoc
- [NEW] Update go mod vendor
- [NEW] Add more event examples
- [NEW] add AddEvents, AddMouse, AddMousePos examples code


### Update

- [NEW] Update event example code add print hint
- [NEW] Update godoc
- [NEW] Update CHANGELOG.md
- [NEW] Update .gitignore
- [NEW] Update code style and examples
- [NEW] Update pkg to newest
- [NEW] Update CI add go1.12.x support
- [NEW] Move GetText() func code

### Fix

- [FIX] Add AddEvents func, Fixed #98, #61, #69...
- [FIX] Add asynchronous event support, Fixed #196, #89...
- [FIX] add AddMouse func, Fixed #138
- [FIX] Update _Ctype_char to C.char, Fixed go1.12 build error #191
- [FIX] Update hook, Fixed #195 warning and json break bug
- [FIX] Fixed color picker, Update README.md and docs


See Commits for more details, after Jan 7.


## RobotGo v0.70.0, Caloris Montes

# Caloris Montes

### Add

- [NEW] Update keyboard use sendInput not keybd_event
- [NEW] Update mouse use sendInput not mouse_event
- [NEW] Add drag mouse other button support
- [NEW] Add more numpad key support
- [NEW] Add numpad key and escape abbreviation support
- [NEW] Add new window10 zoom ratio
- [NEW] Add linux numpad key support
- [NEW] Add key "insert, printscreen" mac support
- [NEW] Add check mouse button func
- [NEW] Add keyTap run error return support and update godoc


 <br/>

- [NEW] Optimize and clearer keytap code
- [NEW] Optimize and clean keyToggle code
- [NEW] Update dockerfile clean image
- [NEW] Add color picker and getMousePos() example
- [NEW] Use go mod not dep, add go.mod remove dep files
- [NEW] Add GetColors func return string
- [NEW] Optimize defer code
<br/>

- [NEW] Add more godoc
- [NEW] Add add key "ctrl", "cmd" [ abbreviation ] support
- [NEW] Add add key "capslock", "numpad_lock" support
- [NEW] Add left and right "Ctrl, Shift, Alt, command" key support
- [NEW] Update check key flags support "cmd" and "ctrl"
- [NEW] Update key docs
- [NEW] Add millisleep func and update godoc
- [NEW] Add AddEvent() key "cmd" support
- [NEW] Update key example code
- [NEW] Update README.md, add Note go1.10.x issue
- [NEW] Update keytap and toggle return "" and code style


### Update

- [NEW] Update issue template more obvious
- [NEW] Update godoc
- [NEW] Update CHANGELOG.md
- [NEW] Update .gitignore
- [NEW] Update code style and examples
- [NEW] Update pkg to newest
- [NEW] Add more scale example
- [NEW] Add drag mouse example
<br/>

- [NEW] Update key docs and clear file name
- [NEW] Remove old useless code
- [NEW] Update README.md
- [NEW] Update CI add go1.11.4 version

### Fix

- [FIX] Fixed bitmapClick() parameter bug
- [FIX] Fixed some README.md typo
- [FIX] Update scale example code close #153
- [FIX] Update code style and fixed #endif error


See Commits for more details, after Otc 8.


## RobotGo v0.60.0, Mount Olympus: Mytikas

### Add

- [NEW] Add GetBounds func support (add get_client and get_frame C_func)
- [NEW] Add GetXId and GetXidFromPid func
- [NEW] Refactoring GetTitle() func allow by pid
- [NEW] Refactoring CloseWindow() allow by pid
- [NEW] Add SetHandPid() and GetHandPid() func support
- [NEW] Add FindCBitmap func support
 <br/>

- [NEW] Refactoring bitmap example code
- [NEW] Refactoring key example code
- [NEW] Refactoring window example code
- [NEW] Add an cbitmap example [#169]
- [NEW] Refactoring screen and event example code
- [NEW] Refactoring mouse example code
<br/>

- [NEW] Add more godoc
- [NEW] Add getTitle example by pid
- [NEW] Add close window example by pid
- [NEW] Add getBounds example
- [NEW] Split func and remove dep more clean
- [NEW] Simplify SaveCapture code
- [NEW] Update and merged get_pixel_color remove duplicate code
- [NEW] Update README.md, add Note go1.10.x


### Update

- [NEW] Update issue template more obvious
- [NEW] Move public mdata to pub
- [NEW] Update godoc
- [NEW] Update CHANGELOG.md
- [NEW] Move some pub method to pub.h and rename some c_func
- [NEW] Update code style and name style ( key, window and other )
- [NEW] Update robotgo unix export getXidFromPid func
- [NEW] Update set handle return use bool
<br/>

- [NEW] Update code style and move scale to win_sys.h
- [NEW] Update example add more lang
- [NEW] Update pkg to newest
- [NEW] Remove duplicate code and old useless code
- [NEW] Update and clean README.md
- [NEW] Update CI add go1.11.x version
- [NEW] Update scroll godoc and clearer parameter name
- [NEW] Update hint and code style
- [NEW] Update FindIds doc and only set name once in loop

### Fix

- [FIX] Update type_string fixed #155, fixed window missing  some character
- [FIX] Fixed GetWindowText return address of local variable and not use ternary operator ( GetTittle )
- [FIX] Update README.md Fixed Release badge

See Commits for more details, after Aug 8.


## RobotGo v0.50.0, The Appalachian Mountains

## Add

- [NEW] Add simple ocr support
- [NEW] Add max and min window api and win32.h file
- [NEW] Automatic free internal bitmap and add bitmapStr example
- [NEW] Update findBitmap and findColor default tolerance 0.5 to 0.01, [improve find accuracy and time]
- [NEW] Add more Window example
- [NEW] Add cross compile docs
- [NEW] Add free bitmap and tolerance godoc
- [NEW] Add GetForegroundWindow and FindWindow func support
- [NEW] Add bitmap to CBitmap func, Add ToCBitmap example to examples
- [NEW] Add get Scale and GetScaleSize func, get primary display DPI scale factor fix #129, #135
   Add Custom DPI Scaling support,
   Add scale default value,
   Add scale example

## Update

- [NEW] Update README.md [add freeBitmap example]
- [NEW] Optimize findColor and uniform API with findBitmap
- [NEW] Update godoc, CI and README.md
- [NEW] Update CHANGELOG.md
- [NEW] Update examples [add freeBitmap and update findColor]
- [NEW] Optimize bitmap code, optimize args and not try [many methods]
- [NEW] Update getPid type to int32
- [NEW] Update var and other code style, fix non-standard code
   Update code and update some name
- [NEW] Update pkg to newest
- [NEW] Remove duplicate code and old useless code
- [NEW] Update mouse click and fix moveClick and movesClick args
- [NEW] Update code style use if not try
- [NEW] Update clipboard example
- [NEW] Update typestr use return not else
- [NEW] Update mouse toggle, keytap and savebitmap func args
- [NEW] Update examples remove duplicate code
- [NEW] Update bitmap and other examples
- [NEW] Simplify linux dependency installation commands
- [NEW] Update issue_template.md
-[NEW] Update pull_request_template.md
- [NEW] Move govendor to dep
- [NEW] Update robotgo ci to 1.10.3

## Fix

- [FIX] Update active pid to fix #140, fixed linux activePid
- [FIX] Fixed findBitmap and findPic memory leak
- [FIX] Add getPxColor destroyMMBitmap fix memory leak
- [FIX] Fix float args not float32
- [FIX] Fix windows clipboard memory leak
- [FIX] Update macos .a downgrade to 10.10 just warning not exit [fix #102, #128, #134]
- [FIX] use 10.10 to compile .a verifyed multi os
- [FIX] Fix #145 not assert
- [FIX] Fix some warning use supplemental code

See Commits for more details, after Apr 30.


## RobotGo v0.49.0, Olympus Mons

### Add

- [NEW] Add get image size func
- [NEW] Add linux type string utf-8 support
- [NEW] Add scroll mouse support x, y
- [NEW] Add AddEvent() "esc" support fix #105
- [NEW] Add AddEvent "space" fix #110
- [NEW] Add clipboard choose primary mode on unix
- [NEW] Add move smooth return
- [NEW] Add more bitmap func and examples
- [NEW] Add MicroSleep func
- [NEW] Add find image by path


### Update

- [NEW] Update KeyToggle code
- [NEW] Update activePid allow Windows via hwnd
- [NEW] Update godoc and README.md
- [NEW] Update CHANGELOG.md
- [NEW] Update Kill() parameter and examples
- [NEW] Update examples and remove useless function
- [NEW] Update appveyor, circle and dockerfile
- [NEW] Update code style
- [NEW] Update and optimize func
- [NEW] Update travis support go 1.10
- [NEW] Update CI (use custom go image) and add func internalFindBitmap
- [NEW] Update godoc and deprecated GetBHandle
- [NEW] Optimize code func args and name


### Fix

- [FIX] Fix mac input method keytap not work
- [FIX] Fix clipboard golint
- [FIX] Update move smooth fix #96 (set mouse smooth speed)
- [FIX] Fix Getportion param to go type
- [FIX] Fix XFlush wait for events flushing

See Commits for more details, after Jan 25.

## RobotGo v0.48.0, Ben Nevis

### Add

- [NEW] Add active window by name func ActiveName
- [NEW] Add type string utf-8 support

Add func CharCodeAt, UnicodeType, PasteStr and update TypeStr, TypeString

- [NEW] Add count of bitmap func CountBitmap
- [NEW] Add func SaveCapture and examples
- [NEW] Add time sleep func Sleep
- [NEW] Add more key listen
- [NEW] Add func PointInBounds and examples
- [NEW] Add func GetPxColor return C.MMRGBHex
- [NEW] Add FindColorCS param tolerance
- [NEW] Add func ToBitmap and examples
- [NEW] Add CBitmap type and examples
- [NEW] Add more examples
- [NEW] Add func ToMMBitmapRef
- [NEW] Add func BitmapClick and MovesClick
- [NEW] Add func ToMMRGBHex convert color hex
- [NEW] Add  func count bitmap color and CountColorCS
- [NEW] Add more color processing and conversion

Add func ToMMRGBHex, U32ToHex, U8ToHex, PadHex, HexToRgb, RgbToHex and examples

- [NEW] Add func tochar bitmap and gostring and fmt code


### Update
- [NEW] Remove robot and examples
- [NEW] Update vendor and appveyor.yml
- [NEW] Update keyboard code
- [NEW] Update godoc
- [NEW] Update CHANGELOG.md
- [NEW] Change TostringBitmap return string
- [NEW] Update C language code and other naming
- [NEW] Update code and code style
- [NEW] Update move mouse smooth


### Fix

- [FIX] Fix mac set active and active by pid
- [FIX] Fix windows active by pid #101
- [FIX] Fix FindColor param tolerance
- [FIX] Fix find bitmap float args
- [FIX] Fix some range error
- [FIX] Update doc fix #97
- [FIX] Update README.md fix link error

See Commits for more details, after Dec 13.

## RobotGo v0.47.0, Mount Cook

### Add

- [NEW] Add windows 32bit and 64bit dependency
- [NEW] Add macOs dependency
- [NEW] Add pkg to vendor

Solve the problem of dependence, remove zlib/libpng dependencies

- [NEW] Add FindColorCS(x, y, w, h int, color CHex), CHex type and examples #84
- [NEW] Add kill the process
- [NEW] Add public event and update code
- [NEW] Add  Windows 32bit and 64bit Appveyor CI


### Update
- [NEW] Update png io
- [NEW] Update cgo link
- [NEW] Update .gitignore
- [NEW] Update README.md and godoc
- [NEW] Update CHANGELOG.md
- [NEW] Update circle to 2.0, add robotgo Dockerfile custom image
- [NEW] Update and fmt C code
- [NEW] Update GetTitle default value "null" to ""


### Fix

- [FIX] Fix FindColor inconvenient parameters
- [FIX] Fix installation requirements #72
- [FIX] Fix GetTitle `return address of local variable` in the higher gcc version. #81

See Commits for more details, after Nov 10.


## RobotGo v0.46.6, Pyrenees Mountains: Aneto Peak

## RobotGo v0.46.0, Pyrenees Mountains

### Add

- [NEW] Add ActivePID
- [NEW] Add FindBit
- [NEW] Add robot branch, where there is no zlib and libpng dependency

### Update

- [NEW] Update README.md
- [NEW] Update FindIds
- [NEW] Update examples
- [NEW] Update vendor
- [NEW] Update godoc and docs
- [NEW] Update and fix bitmap

### Fix

- [FIX] Fix MoveMouseSmooth args
- [FIX] Fix name err
- [FIX] Fix FindBitmap

## RobotGo v0.45.0, Mount Qomolangma

### Add
- [NEW] Add Process
- [NEW] Add TypeStr
- [NEW] Add DeepCopyBit
- [NEW] Add CopyBitpb
- [NEW] Add ReadBitmap
- [NEW] Add vendor.json
- [NEW] Add ReadAll: clipboard
- [NEW] Add WriteAll: clipboard
- [NEW] Add Pids : get the all process id
- [NEW] Add FindName: find the process name by the process id
- [NEW] Add FindNames: find the all process name
- [NEW] Add PidExists: determine whether the process exists
- [NEW] Add FindIds: find the process id by the process name
- [NEW] Add FreeBitmap and Update docs


### Update
- [NEW] Update docs
- [NEW] Update test
- [NEW] Update godoc
- [NEW] Update CHANGELOG.md
- [NEW] Update .gitignore
- [NEW] Update examples and docs
- [NEW] Update examples link
- [NEW] Update README.md and clipboard


### Fix

- [FIX] Fix release key
- [FIX] Fix godoc error


## RobotGo v0.44.0, Mount Kailash

### Add

- Add CHANGELOG.md
- Format some code
- Add fedora dependencies

### Update

- Update test
- Update keys.md
- Update and Split example
- Update godoc and docs
- Update and Cleanup README.md
- Update CONTRIBUTING.md and issue_template.md

### Fix

- Fix typesetting and MD error
- Fix fedora dependencies #55
- Fix doc.md and README.md

---

### Install (`docs/install.md`)

## CGO CrossCompiling

##### Windows64 to windows32

```Go
SET CGO_ENABLED=1
SET GOARCH=386
go build main.go
```

#### Other to windows

Install Requirements (Ubuntu):

```bash
sudo apt install gcc-multilib
sudo apt install gcc-mingw-w64
# fix err: zlib.h: No such file or directory, Just used by bitmap.
sudo apt install libz-mingw-w64-dev
```

Build the binary:

```Go
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ go build -x ./
```

```
// CC=mingw-w64\x86_64-7.2.0-win32-seh-rt_v5-rev1\mingw64\bin\gcc.exe
// CXX=mingw-w64\x86_64-7.2.0-win32-seh-rt_v5-rev1\mingw64\bin\g++.exe
```

Some discussions and questions, please see [issues/228](https://github.com/go-vgo/robotgo/issues/228), [issues/143](https://github.com/go-vgo/robotgo/issues/143).

---

### Keys (`docs/keys.md`)

## Type Conversion

|     | type conversion                   | func                    |
| --- | --------------------------------- | ----------------------- |
| \*  | robotgo.Bitmap -> robotgo.CBitmap | robotgo.ToCBitmap()     |
|     | robotgo.Bitmap -> \*image.RGBA    | robotgo.ToRGBAGo()      |
| \*  | robotgo.CBitmap -> C.MMBitmapRef  | robotgo.ToMMBitmapRef() |
|     | robotgo.CBitmap -> robotgo.Bitmap | robotgo.ToBitmap()      |
|     | robotgo.CBitmap -> image.Image    | robotgo.ToImage()       |
|     | robotgo.CBitmap -> \*image.RGBA   | robotgo.ToRGBA()        |
| \*  | C.MMBitmapRef -> robotgo.CBitmap  | robotgo.CBitmap()       |
| \*  | image.Image -> robotgo.Bitmap     | robotgo.ImgToBitmap()   |
|     | image.Image -> robotgo.CBitmap    | robotgo.ImgToCBitmap()  |
|     | image.Image -> []byte             | robotgo.ToByteImg()     |
|     | image.Image -> string             | robotgo.ToStringImg()   |
| \*  | \*image.RGBA -> robotgo.Bitmap    | robotgo.RGBAToBitmap()  |
| \*  | []byte -> image.Image             | robotgo.ByteToImg()     |
|     | []byte-> robotgo.CBitmap          | robotgo.ByteToCBitmap() |
|     | []byte -> string                  | string()                |
| \*  | string -> image.Image             | robotgo.StrToImg()      |
|     | string -> byte                    | []byte()                |

# Keys

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

### Archive README Zh (`docs/archive/README_zh.md`)

# Robotgo

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

[](https://github.com/go-vgo/robotgo/commits/master)
[](https://circleci.com/gh/go-vgo/robotgo)
[](https://travis-ci.org/go-vgo/robotgo)

[](https://goreportcard.com/report/github.com/go-vgo/robotgo)
[](https://godoc.org/github.com/go-vgo/robotgo)
[](https://github.com/go-vgo/robotgo/releases/latest)
[](https://gitter.im/go-vgo/robotgo?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

> Golang 跨平台自动化系统，控制键盘、鼠标、位图、图像、读取屏幕，进程、窗口句柄以及全局事件监听

RobotGo 支持 Mac, Windows, and Linux(X11).

<br>

提 Issues 请到 [Github](https://github.com/go-vgo/robotgo), 便于统一管理和即时更新; `REDAME_zh.md 已废弃, 不再更新`

## Contents

- [Docs](#docs)
- [Binding](#binding)
- [Requirements](#requirements)
- [Installation](#installation)
- [Update](#update)
- [Examples](#examples)
- [Cross-Compiling](#crosscompiling)
- [Authors](#authors)
- [Plans](#plans)
- [Donate](#donate)
- [Contributors](#contributors)
- [License](#license)

## Docs

- [GoDoc](https://godoc.org/github.com/go-vgo/robotgo) <br>



## Binding:

[Robotn](https://github.com/vcaesar/robotn), binding JavaScript and other, support more language.

## Requirements:

环境要求:

在安装 RobotGo 之前, 请确保 `Golang、GCC` 被正确安装

### ALL:

```
Golang

GCC
```

#### For Mac OS X:

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

```
xcode-select --install
```

#### For Windows:

[MinGW-w64](https://sourceforge.net/projects/mingw-w64/files) (推荐使用)

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

#### For everything else (Linux 等其他系统):

```
GCC,
libpng(bitmap)

X11 with the XTest extension (also known as the Xtst library)

事件:

xcb, xkb, libxkbcommon

Clipboard:

xsel xclip
```

##### Ubuntu:

```yml
sudo apt install gcc libc6-dev

sudo apt install libx11-dev xorg-dev libxtst-dev libpng++-dev

sudo apt install xcb libxcb-xkb-dev x11-xkb-utils libx11-xcb-dev libxkbcommon-x11-dev libxkbcommon-dev

sudo apt install xsel xclip
```

##### Fedora:

```yml
sudo dnf install libXtst-devel libxkbcommon-devel libxkbcommon-x11-devel xorg-x11-xkb-utils-devel

sudo dnf install libpng-devel

sudo dnf install xsel xclip
```

## Installation:

With Go module support (Go 1.11+), just import:

```go
import "github.com/go-vgo/robotgo"
```

Otherwise, to install the robotgo package, run the command:

```
go get github.com/go-vgo/robotgo
```

png.h: No such file or directory? Please see [issues/47](https://github.com/go-vgo/robotgo/issues/47).

## Update:

```
go get -u github.com/go-vgo/robotgo
```

注意 go1.10.x C 文件编译缓存问题, [golang #24355](https://github.com/golang/go/issues/24355).
`go mod vendor` problem, [golang #26366](https://github.com/golang/go/issues/26366).

## [Examples:](https://github.com/go-vgo/robotgo/blob/master/examples)

#### [鼠标](https://github.com/go-vgo/robotgo/blob/master/examples/mouse/main.go)

```Go
package main

import (
	"github.com/go-vgo/robotgo"
)

func main() {
  // robotgo.ScrollMouse(10, "up")
  robotgo.Scroll(0, -10)
  robotgo.Scroll(100, 0)
  robotgo.MilliSleep(100)
  // robotgo.ScrollRelative(10, -100)
  robotgo.ScrollSmooth(-10, 6)

  robotgo.MouseSleep = 100
  robotgo.Move(10, 20)
  robotgo.MoveRelative(0, -10)
  robotgo.Drag(10, 10)

  robotgo.Click("left", true)
  robotgo.MoveSmooth(100, 200, 1.0, 10.0)

  robotgo.Toggle("left")
  robotgo.Toggle("left", "up")
}
```

#### [键盘](https://github.com/go-vgo/robotgo/blob/master/examples/key/main.go)

```Go
package main

import (
  "fmt"

  "github.com/go-vgo/robotgo"
)

func main() {
  robotgo.TypeStr("Hello World. Winter is coming!")
  robotgo.TypeStr("だんしゃり", 1.0)
  // robotgo.TypeStr("テストする")

  robotgo.TypeStr("Hi galaxy. こんにちは世界.")
  robotgo.Sleep(1)

  // ustr := uint32(robotgo.CharCodeAt("テストする", 0))
  // robotgo.UnicodeType(ustr)

  robotgo.KeySleep = 100
  robotgo.KeyTap("enter")
  // robotgo.TypeStr("en")
  robotgo.KeyTap("i", "alt", "command")

  arr := []string{"alt", "command"}
  robotgo.KeyTap("i", arr)

  robotgo.MilliSleep(100)
  robotgo.KeyToggle("a")
  robotgo.KeyToggle("a", "up")

  robotgo.WriteAll("テストする")
  text, err := robotgo.ReadAll()
  if err == nil {
    fmt.Println(text)
  }
}
```

#### [屏幕](https://github.com/go-vgo/robotgo/blob/master/examples/screen/main.go)

```Go
package main

import (
	"fmt"

	"github.com/go-vgo/robotgo"
  "github.com/vcaesar/imgo"
)

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

  color := robotgo.GetPixelColor(100, 200)
  fmt.Println("color----", color)

  sx, sy := robotgo.GetScreenSize()
  fmt.Println("get screen size: ", sx, sy)

  bit := robotgo.CaptureScreen(10, 10, 30, 30)
  defer robotgo.FreeBitmap(bit)
  robotgo.SaveBitmap(bit, "test_1.png")

  img := robotgo.ToImage(bit)
  imgo.Save("test.png", img)
}
```

#### [位图](https://github.com/go-vgo/robotgo/blob/master/examples/bitmap/main.go)

```Go
package main

import (
	"fmt"

	"github.com/go-vgo/robotgo"
)

func main() {
  bitmap := robotgo.CaptureScreen(10, 20, 30, 40)
  // use `defer robotgo.FreeBitmap(bit)` to free the bitmap
  defer robotgo.FreeBitmap(bitmap)

  fmt.Println("bitmap...", bitmap)
  img := robotgo.ToImage(bitmap)
  robotgo.SavePng(img, "test_1.png")

  bit2 := robotgo.ToCBitmap(robotgo.ImgToBitmap(img))
  fx, fy := robotgo.FindBitmap(bit2)
  fmt.Println("FindBitmap------ ", fx, fy)
  robotgo.Move(fx, fy)

  arr := robotgo.FindAllBitmap(bit2)
  fmt.Println("Find all bitmap: ", arr)
  robotgo.SaveBitmap(bitmap, "test.png")

  fx, fy = robotgo.FindBitmap(bitmap)
  fmt.Println("FindBitmap------", fx, fy)

  robotgo.SaveBitmap(bitmap, "test.png")
}
```

#### [OpenCV](https://github.com/vcaesar/gcv)

```Go
package main

import (
  "fmt"
  "math/rand"

  "github.com/go-vgo/robotgo"
  "github.com/vcaesar/gcv"
)

func main() {
  opencv()
}

func opencv() {
  name := "test.png"
  name1 := "test_001.png"
  robotgo.SaveCapture(name1, 10, 10, 30, 30)
  robotgo.SaveCapture(name)

  fmt.Print("gcv find image: ")
  fmt.Println(gcv.FindImgFile(name1, name))
  fmt.Println(gcv.FindAllImgFile(name1, name))

  bit := robotgo.OpenBitmap(name1)
  defer robotgo.FindBitmap(bit)
  fmt.Print("find bitmap: ")
  fmt.Println(robotgo.FindBitmap(bit))

  // bit0 := robotgo.CaptureScreen()
  // img := robotgo.ToImage(bit0)
  // bit1 := robotgo.CaptureScreen(10, 10, 30, 30)
  // img1 := robotgo.ToImage(bit1)
  // defer robotgo.FreeBitmapArr(bit0, bit1)
  img := robotgo.CaptureImg()
  img1 := robotgo.CaptureImg(10, 10, 30, 30)

  fmt.Print("gcv find image: ")
  fmt.Println(gcv.FindImg(img1, img))
  fmt.Println()

  res := gcv.FindAllImg(img1, img)
  fmt.Println(res[0].TopLeft.Y, res[0].Rects.TopLeft.X, res)
  x, y := res[0].TopLeft.X, res[0].TopLeft.Y
  robotgo.Move(x, y-rand.Intn(5))
  robotgo.MilliSleep(100)
  robotgo.Click()

  res = gcv.FindAll(img1, img) // use find template and sift
  fmt.Println("find all: ", res)
  res1 := gcv.Find(img1, img)
  fmt.Println("find: ", res1)

  img2, _, _ := robotgo.DecodeImg("test_001.png")
  x, y = gcv.FindX(img2, img)
  fmt.Println(x, y)
}
```

#### [事件](https://github.com/go-vgo/robotgo/blob/master/examples/gohook/main.go)

```Go
package main

import (
  "fmt"

  "github.com/go-vgo/robotgo"
  hook "github.com/robotn/gohook"
)

func main() {
  add()
  low()
  event()
}

func add() {
  fmt.Println("--- Please press ctrl + shift + q to stop hook ---")
  robotgo.EventHook(hook.KeyDown, []string{"q", "ctrl", "shift"}, func(e hook.Event) {
    fmt.Println("ctrl-shift-q")
    robotgo.EventEnd()
  })

  fmt.Println("--- Please press w---")
  robotgo.EventHook(hook.KeyDown, []string{"w"}, func(e hook.Event) {
    fmt.Println("w")
  })

  s := robotgo.EventStart()
  <-robotgo.EventProcess(s)
}

func low() {
	evChan := hook.Start()
	defer hook.End()

	for ev := range evChan {
		fmt.Println("hook: ", ev)
	}
}

func event() {
  ok := robotgo.AddEvents("q", "ctrl", "shift")
  if ok {
    fmt.Println("add events...")
  }

  keve := robotgo.AddEvent("k")
  if keve {
    fmt.Println("you press... ", "k")
  }

  mleft := robotgo.AddEvent("mleft")
  if mleft {
    fmt.Println("you press... ", "mouse left button")
  }
}
```

#### [窗口句柄](https://github.com/go-vgo/robotgo/blob/master/examples/window/main.go)

```Go
package main

import (
	"fmt"

	"github.com/go-vgo/robotgo"
)

func main() {
  fpid, err := robotgo.FindIds("Google")
  if err == nil {
    fmt.Println("pids...", fpid)

    if len(fpid) > 0 {
      robotgo.ActivePID(fpid[0])

      robotgo.Kill(fpid[0])
    }
  }

  robotgo.ActiveName("chrome")

  isExist, err := robotgo.PidExists(100)
  if err == nil && isExist {
    fmt.Println("pid exists is", isExist)

    robotgo.Kill(100)
  }

  abool := robotgo.Alert("test", "robotgo")
  if abool {
    fmt.Println("ok@@@ ", "ok")
  }

  title := robotgo.GetTitle()
  fmt.Println("title@@@ ", title)
}
```

## CrossCompiling

##### Windows64 to windows32

```Go
SET CGO_ENABLED=1
SET GOARCH=386
go build main.go
```

#### Other to windows

Install Requirements (Ubuntu):

```bash
sudo apt install gcc-multilib
sudo apt install gcc-mingw-w64
sudo apt install libz-mingw-w64-dev
```

Build the binary:

```Go
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ go build -x ./
```

```
// CC=mingw-w64\x86_64-7.2.0-win32-seh-rt_v5-rev1\mingw64\bin\gcc.exe
// CXX=mingw-w64\x86_64-7.2.0-win32-seh-rt_v5-rev1\mingw64\bin\g++.exe
```

## Authors

- [The author is vz](https://github.com/vcaesar)
- [Maintainers](https://github.com/orgs/go-vgo/people)
- [Contributors](https://github.com/go-vgo/robotgo/graphs/contributors)

## Plans

- 更新 Find an image on screen, read pixels from an image
- 更新 Window Handle
- 尝试支持 Android, 也许支持 IOS

## Contributors

- See [contributors page](https://github.com/go-vgo/robotgo/graphs/contributors) for full list of contributors.
- See [Contribution Guidelines](https://github.com/go-vgo/robotgo/blob/master/CONTRIBUTING.md).

## License

Robotgo is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.

See [LICENSE-APACHE](http://www.apache.org/licenses/LICENSE-2.0), [LICENSE-MIT](https://github.com/go-vgo/robotgo/blob/master/LICENSE).

---

### Archive Doc (`docs/archive/doc.md`)

# Methods:

##### [GetVersion](#GetVersion)

## [Keyboard](#Keyboard)

##### [Keys](https://github.com/go-vgo/robotgo/blob/master/docs/keys.md)

##### [SetKeyDelay](#SetKeyDelay)
##### [KeyTap](#KeyTap)
##### [KeyToggle](#KeyToggle)

##### [TypeStr](#TypeStr)
##### [TypeStrDelay](#TypeStrDelay)
##### [WriteAll](#WriteAll)
##### [ReadAll](#ReadAll)


## [Mouse](#Mouse)

##### [SetMouseDelay](#SetMouseDelay)
##### [MoveMouse](#MoveMouse)
##### [Move](#MoveMouse) (Equivalent to MoveMouse)
##### [MoveMouseSmooth](#MoveMouseSmooth)
##### [MoveSmooth](#MoveMouseSmooth) (Equivalent to MoveMouseSmooth)
##### [MouseClick](#MouseClick)
##### [Click](#MouseClick) (Equivalent to MouseClick)
##### [MoveClick](#MoveClick)
##### [MouseToggle](#MouseToggle)
##### [DragMouse](#DragMouse)
##### [Drag](#DragMouse) (Equivalent to DragMouse)
##### [GetMousePos](#GetMousePos)
##### [ScrollMouse](#ScrollMouse)

## [Screen](#Screen)

##### [GetPixelColor](#GetPixelColor)
##### [GetScreenSize](#GetScreenSize)
##### [CaptureScreen](#CaptureScreen)
##### [GetXDisplayName(Linux)](#GetXDisplayName)
##### [SetXDisplayName(Linux)](#SetXDisplayName)

## [Bitmap](#Bitmap)
    This is a work in progress.

##### [FindBitmap](#FindBitmap)
##### [OpenBitmap](#OpenBitmap)
##### [SaveBitmap](#SaveBitmap)
##### [TostringBitmap](#TostringBitmap)
##### [GetPortion](#GetPortion)
##### [Convert](#Convert)
#### [FreeBitmap](#FreeBitmap)
#### [ReadBitmap](#ReadBitmap)
#### [CopyBitpb](#CopyBitpb)
#### [DeepCopyBit](#DeepCopyBit)

## [Event](#Event)


##### [AddEvent](#AddEvent)
##### [StopEvent](#StopEvent)

## [Window](#Window)
    This is a work in progress.

##### [ShowAlert](#ShowAlert)
##### [CloseWindow](#CloseWindow)
##### [IsValid](#IsValid)
##### [SetActive](#SetActive)
##### [GetActive](#GetActive)
##### [SetHandle](#SetHandle)
##### [GetHandle](#GetHandle)

##### [GetTitle](#GetTitle)
##### [GetPID](#GetPID)
##### [Pids](#Pids)
##### [PidExists](#PidExists)
##### [Process](#Process)
##### [FindName](#FindName)
##### [FindNames](#FindNames)
##### [FindIds](#FindIds)
#### [ActivePID](#ActivePID)

### <h3 id="GetVersion">.GetVersion()</h3>
    Get robotgo version

## <h2 id="Keyboard">Keyboard</h2>

### <h3 id="SetKeyDelay">.SetKeyDelay(ms)</h3>

    Sets the delay in milliseconds to sleep after a keyboard event. This is 10ms by default.

#### Arguments:

    ms - Time to sleep in milliseconds.

### <h3 id="KeyTap">.KeyTap(key, modifier)</h3>

    Press a single key.

#### Arguments:

key - See [keys](https://github.com/go-vgo/robotgo/blob/master/docs/keys.md).  
modifier (optional, string or array) - Accepts alt, command (win), control, and shift.

#### Examples:

```Go
robotgo.KeyTap("h", "command")
robotgo.KeyTap("i", "alt", "command")
arr := []string{"alt", "command"}
robotgo.KeyTap("i", arr)
```

### <h3 id="KeyToggle">.KeyToggle(key, down, modifier)</h3>

    Hold down or release a key.

#### Arguments:

key - See [keys](https://github.com/go-vgo/robotgo/blob/master/docs/keys.md).  
down - Accepts 'down' or 'up'.  
modifier (optional, string or array) - Accepts alt, command (mac), control, and shift.

#### Return:
    return KeyToggle status



### <h3 id="TypeStr">.TypeStr(string)</h3>

#### Arguments:

    string - The string to send.

### <h3 id="TypeStrDelay">.TypeStrDelay(string, cpm)</h3>

#### Arguments:

    string - The string to send.
    cpm - Characters per minute.

### <h3 id="WriteAll">.WriteAll(text string)</h3>

#### Arguments:
    text string
#### Return:      

### <h3 id="ReadAll">.ReadAll()</h3>

#### Arguments:

#### Return: 
    text,
    error 


## <h2 id="Mouse">Mouse</h2>

### <h3 id="SetMouseDelay">.SetMouseDelay(ms)</h3>

    Sets the delay in milliseconds to sleep after a mouse event. This is 10ms by default.

#### Arguments:

    ms - Time to sleep in milliseconds.

### <h3 id="MoveMouse">.MoveMouse(x, y)</h3>

    Moves mouse to x, y instantly, with the mouse button up.

#### Arguments:

    x, y

#### Examples:

```Go
// Move the mouse to 100, 100 on the screen. 
robotgo.MoveMouse(100, 100)
```

### <h3 id="MoveMouseSmooth">.MoveMouseSmooth(x, y)</h3>

    Moves mouse to x, y human like, with the mouse button up.

#### Arguments:

    x, y
    lowspeed, highspeed

#### Examples:

```Go
robotgo.MoveMouseSmooth(100, 200)
robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0)
```    

### <h3 id="MouseClick">.MouseClick(button, double)</h3>

    Clicks the mouse.

#### Arguments:

    button (optional) - Accepts "left", "right", or "center". Defaults to left.
    double (optional) - Set to true to perform a double click. Defaults to false.

#### Examples:

```Go
robotgo.MouseClick()
robotgo.MouseClick("left", true)
```

### <h3 id="MoveClick">.MoveClick(x, y, button, double)</h3>

    Move and click the mouse.

#### Arguments:
    x,
    y,

    button (optional) - Accepts "left", "right", or "center". Defaults to left.
    double (optional) - Set to true to perform a double click. Defaults to false.

#### Examples:

```Go
robotgo.MoveClick(10, 20)
robotgo.MoveClick(10, 20, "left", true)
```

### <h3 id="MouseToggle">.MouseToggle(down, button)</h3>

    Toggles mouse button.

#### Arguments:

    down (optional) - Accepts down or up. Defaults to down.
    button (optional) - Accepts "left", "right", or "center". Defaults to left.

#### Examples:

```Go
robotgo.MouseToggle("down")
robotgo.MouseToggle("down", "right")
```

### <h3 id="DragMouse">.DragMouse(x, y)</h3>

    Moves mouse to x, y instantly, with the mouse button held down.

#### Arguments:

    x, y

#### Examples:

```Go
// Mouse down at 0, 0 and then drag to 100, 100 and release. 
robotgo.MoveMouse(0, 0)
robotgo.MouseToggle("down")
robotgo.DragMouse(100, 100)
robotgo.MouseToggle("up")
```

### <h3 id="GetMousePos">.GetMousePos()</h3>

    Gets the mouse coordinates.

#### Return:

    Returns an object with keys x and y.

#### Examples:

```Go
x,y := robotgo.GetMousePos()
fmt.Println("pos:", x, y)
```

### <h3 id="ScrollMouse">.ScrollMouse(magnitude, direction)</h3>

    Scrolls the mouse either up or down.

#### Arguments:

    magnitude - The amount to scroll.
    direction - Accepts down or up.

#### Examples:

```Go
robotgo.ScrollMouse(50, "up")

robotgo.ScrollMouse(50, "down")
```


## <h2 id="Screen">Screen</h2>

### <h3 id="GetPixelColor">.GetPixelColor(x, y)

    Gets the pixel color at x, y. This function is perfect for getting a pixel or two, 
    but if you'll be reading large portions of the screen use screen.capture.

#### Arguments:

    x, y

#### Return:

    Returns the hex color code of the pixel at x, y.

### <h3 id="GetScreenSize">.GetScreenSize()</h3>

    Gets the screen width and height.

#### Return:

    Returns an object with .width and .height.

### <h3 id="CaptureScreen">.CaptureScreen</h3>
    // CaptureScreen

    Gets part or all of the screen.

    GoCaptureScreen Returns a go struct


#### Arguments:

    x (optional)
    y (optional)
    height (optional)
    width (optional)
    If no arguments are provided, capturescreen(screencapture) will get the full screen.

#### Return:

    Returns a bitmap object.

## <h2 id="Bitmap">Bitmap</h2>

    This is a work in progress.

### <h3 id="FindBitmap">.FindBitmap</h3>

    find bitmap.

#### Arguments:

    bitmap;
    rect(optional): x, y, w, h

#### Return:

    Returns a position x and y


### <h3 id="OpenBitmap">.OpenBitmap</h3>

    open bitmap.

#### Arguments:

    bitmap image path,
    MMImageType (optional) 

#### Return:

    Returns a bitmap

### <h3 id="SaveBitmap">.SaveBitmap</h3>

    Save a image with bitmap.

#### Arguments:

    bitmap,
    path,
    imagetype (int) 

#### Return:

    return save image status


### <h3 id="TostringBitmap">.TostringBitmap</h3>

     bitmap to string

#### Arguments:

    bitmap 

#### Return:

    Return a sting bitmap

### <h3 id="GetPortion">.GetPortion</h3>

     bitmap from a portion

#### Arguments:

    bitmap,
    rect: x, y, w, h 

#### Return:

    Returns new bitmap object created from a portion of another 

### <h3 id="Convert">.Convert(openpath, savepath, MMImageType)</h3>

    Convert the image format

#### Arguments:

    openpath,
    savepath,
    MMImageType (optional)

#### Examples:

```Go
robotgo.Convert("test.png", "test.tif")
```             

### <h3 id="FreeBitmap">.FreeBitmap(MMBitmapRef)</h3>

    FreeBitmap free and dealloc bitmap

#### Arguments:

    MMBitmapRef

#### Examples:

```Go
robotgo.FreeBitmap(bitmap)
```    


### <h3 id="ReadBitmap">.ReadBitmap(MMBitmapRef)</h3>

    ReadBitmap returns false and sets error if |bitmap| is NULL

#### Arguments:

    MMBitmapRef

#### Return:

    bool

#### Examples:

```Go
robotgo.ReadBitmap(bitmap)
```    


### <h3 id="CopyBitpb">.CopyBitpb(MMBitmapRef)</h3>

   CopyBitpb copy bitmap to pasteboard

#### Arguments:

    MMBitmapRef

#### Return:

    bool

#### Examples:

```Go
robotgo.CopyBitpb(bitmap)
```    

### <h3 id="DeepCopyBit">.DeepCopyBit(MMBitmapRef)</h3>

   DeepCopyBit deep copy bitmap

#### Arguments:

    MMBitmapRef

#### Return:

    MMBitmapRef

#### Examples:

```Go
robotgo.DeepCopyBit(bitmap)
```  

## <h2 id="Event">Event</h2> 

### <h3 id="AddEvent">.AddEvent(string)</h3>

    Listening global event

#### Arguments:

    string

    (mouse arguments: mleft, mright, wheelDown, wheelUp, wheelLeft, wheelRight)

#### Return:

    if listened return 0

#### Examples:

```Go
package main

import (
    "fmt"

    "github.com/go-vgo/robotgo"
)

func main() {
  keve := robotgo.AddEvent("k")
  if keve {
    fmt.Println("you press...", "k")
  }

  mleft := robotgo.AddEvent("mleft")
  if mleft {
    fmt.Println("you press...", "mouse left button")
  }
} 
```  
### <h3 id="StopEvent">.StopEvent()</h3>  
    stop listen global event

## <h2 id="Window">Window</h2> 

### <h3 id="ShowAlert">.ShowAlert(title, msg, defaultButton, cancelButton string)</h3>

    Displays alert with the given attributes. If cancelButton is not given, only the defaultButton is displayed

#### Arguments:

    title (string),
    msg (string),
    defaultButton (optional string),
    cancelButton (optional string)
           

#### Return:

    Returns 0(True) if the default button was pressed, or 1(False) if cancelled. 

### <h3 id="CloseWindow">.CloseWindow()</h3>

    Close the Window

#### Arguments:
    None     

#### Return:
    None

### <h3 id="IsValid">.IsValid()</h3>

    Valid the Window

#### Arguments:
    None     

#### Return:
    Returns true if a window has been selected


### <h3 id="SetActive">.SetActive()</h3>

   Set the Active Window

#### Arguments:
    hwnd  

#### Return:
    void
    

### <h3 id="GetActive">.GetActive()</h3>

    Get the Active Window

#### Arguments:
    None   

#### Return:
    Returns hwnd

### <h3 id="SetHandle">.SetHandle()</h3>

    Set the Window Handle

#### Arguments:
    int 

#### Return:
    bool

### <h3 id="GetHandle">.GetHandle()</h3>

    Get the Window Handle

#### Arguments:
    None    

#### Return:
    Returns hwnd  

### <h3 id="GetTitle">.GetTitle()</h3>

    Get the Window Title

#### Arguments:
    None   

#### Return:
    Returns Window Title      

### <h3 id="GetPID">.GetPID()</h3>

    Get the process id

#### Arguments:
    None       

#### Return:
    Returns the process id         
     
### <h3 id="Pids">.Pids()</h3>

    Pids get the all process id

#### Arguments:
    None   

#### Return:
    Returns all process id   

### <h3 id="PidExists">.PidExists()</h3>

    PidExists determine whether the process exists

#### Arguments:
    pid  

#### Return:
    Returns bool 

### <h3 id="Process">.Process()</h3>

  Process get the all process struct

#### Arguments:
    none  

#### Return:
    Returns []Nps, error

### <h3 id="FindName">.FindName()</h3>

    FindName find the process name by the process id

#### Arguments:
    pid  

#### Return:
    Returns string, error       

### <h3 id="FindNames">.FindNames()</h3>

    FindNames find the all process name

#### Arguments:
    none  

#### Return:
    Returns []string, error  

### <h3 id="FindIds">.FindIds()</h3>

    FindIds find the process id by the process name

#### Arguments:
    name string  

#### Return:
    Returns []int32, error 


### <h3 id="ActivePID">.ActivePID()</h3>

    ActivePID window active by PID

#### Arguments:
    pid int32 

#### Return:
    none

---

### Archive Doc Zh (`docs/archive/doc_zh.md`)

# 方法:

##### [GetVersion](#GetVersion)

## [键盘](#Keyboard)

##### [Keys](https://github.com/go-vgo/robotgo/blob/master/docs/keys.md)

##### [SetKeyDelay](#SetKeyDelay)
##### [KeyTap](#KeyTap)
##### [KeyToggle](#KeyToggle)

##### [TypeStr](#TypeStr)
##### [TypeStrDelay](#TypeStrDelay)
##### [WriteAll](#WriteAll)
##### [ReadAll](#ReadAll)

## [鼠标](#Mouse)

##### [SetMouseDelay](#SetMouseDelay)
##### [MoveMouse](#MoveMouse)
##### [Move](#MoveMouse) (相当于 MoveMouse)
##### [MoveMouseSmooth](#MoveMouseSmooth)
##### [MoveSmooth](#MoveMouseSmooth) (相当与 MoveMouseSmooth)
##### [MouseClick](#MouseClick)
##### [Click](#MouseClick) (相当于 MouseClick)
##### [MoveClick](#MoveClick)
##### [MouseToggle](#MouseToggle)
##### [DragMouse](#DragMouse)
##### [Drag](#DragMouse) (相当于 DragMouse)
##### [GetMousePos](#GetMousePos)
##### [ScrollMouse](#ScrollMouse)

### <h3 id="GetVersion">.GetVersion()</h3>
    获取 robotgo 版本

## [屏幕](#Screen)

##### [GetPixelColor](#GetPixelColor)
##### [GetScreenSize](#GetScreenSize)
##### [CaptureScreen](#CaptureScreen)
##### [GetXDisplayName(Linux)](#GetXDisplayName)
##### [SetXDisplayName(Linux)](#SetXDisplayName)

## [位图](#Bitmap)
    This is a work in progress. (工作正在进行中)

##### [FindBitmap](#FindBitmap)
##### [OpenBitmap](#OpenBitmap)
##### [SaveBitmap](#SaveBitmap)
##### [TostringBitmap](#TostringBitmap)
##### [GetPortion](#GetPortion)
##### [Convert](#Convert)
#### [FreeBitmap](#FreeBitmap)
#### [ReadBitmap](#ReadBitmap)
#### [CopyBitpb](#CopyBitpb)
#### [DeepCopyBit](#DeepCopyBit)

## [事件](#Event)


##### [AddEvent](#AddEvent)
##### [StopEvent](#StopEvent)

## [窗口](#Window)
    This is a work in progress.

##### [ShowAlert](#ShowAlert)
##### [CloseWindow](#CloseWindow)
##### [IsValid](#IsValid)
##### [SetActive](#SetActive)
##### [GetActive](#GetActive)
##### [SetHandle](#SetHandle)
##### [GetHandle](#GetHandle)

##### [GetTitle](#GetTitle)
##### [GetPID](#GetPID)
##### [Pids](#Pids)
##### [PidExists](#PidExists)
##### [Process](#Process)
##### [FindName](#FindName)
##### [FindNames](#FindNames)
##### [FindIds](#FindIds)
#### [ActivePID](#ActivePID)


## <h2 id="Keyboard">键盘</h2>

### <h3 id="SetKeyDelay">.SetKeyDelay(ms)</h3>
    设置键盘延迟 (在键盘一个事件后), 单位 ms, 默认值 10ms

    Sets the delay in milliseconds to sleep after a keyboard event. This is 10ms by default.

#### 参数:
    延迟时间,单位 ms

    ms - Time to sleep in milliseconds.

### <h3 id="KeyTap">.KeyTap(key, modifier)</h3>
    模拟键盘按键

    Press a single key.

#### 参数:
    键盘值
    修饰值 (可选类型, 字符串或者数组) - 可选值: alt, command (win), control, and shift.

key - See [keys](https://github.com/go-vgo/robotgo/blob/master/docs/keys.md).  
modifier (optional, string or array) - Accepts alt, command (win), control, and shift.
#### 示例:

```Go
robotgo.KeyTap("h", "command")
robotgo.KeyTap("i", "alt", "command")
arr := []string{"alt", "command"}
robotgo.KeyTap("i", arr)
```

### <h3 id="KeyToggle">.KeyToggle(key, down, modifier)</h3>
    键盘切换, 按住或释放一个键位

    Hold down or release a key.

#### 参数:

key - See [keys](https://github.com/go-vgo/robotgo/blob/master/docs/keys.md).  
down - Accepts 'down' or 'up'.  
modifier (optional, string or array) - Accepts alt, command (mac), control, and shift.
### 返回值:

    返回 KeyToggle 状态



### <h3 id="TypeStr">.TypeStr(string)</h3>

#### 参数:

    string - The string to send.


### <h3 id="TypeStrDelay">.TypeStrDelay(string, cpm)</h3>

#### 参数:

    string - The string to send.
    cpm - Characters per minute.

### <h3 id="WriteAll">.WriteAll(text string)</h3>

#### 参数:
    text string
#### 返回值:      

### <h3 id="ReadAll">.ReadAll()</h3>

#### 参数:

#### 返回值: 
    text,
    error 

## <h2 id="Mouse">鼠标</h2>
### <h3 id="SetMouseDelay">.SetMouseDelay(ms)</h3>
    设置鼠标延迟 (在一个鼠标事件后), 单位 ms, 默认值 10 ms

    Sets the delay in milliseconds to sleep after a mouse event. This is 10ms by default.

#### 参数:

    ms - Time to sleep in milliseconds.

### <h3 id="MoveMouse">.MoveMouse(x, y)</h3>
    移动鼠标

    Moves mouse to x, y instantly, with the mouse button up.

#### 参数:

    x, y

#### 示例:

```Go
// Move the mouse to 100, 100 on the screen. 
robotgo.MoveMouse(100, 100)
```

### <h3 id="MoveMouseSmooth">.MoveMouseSmooth(x, y)</h3>
    模拟鼠标向 X，Y 平滑移动(像人类一样)，用鼠标按钮向上

    Moves mouse to x, y human like, with the mouse button up.

#### 参数:

    x, y
    lowspeed, highspeed

#### 示例:

```Go
robotgo.MoveMouseSmooth(100, 200)
robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0)
```       

### <h3 id="MouseClick">.MouseClick(button, double)</h3>
    鼠标点击

    Clicks the mouse.

#### 参数:

    button (optional) - Accepts left, right, or center. Defaults to left.
    double (optional) - Set to true to perform a double click. Defaults to false.

#### 示例:

```Go
robotgo.MouseClick()
robotgo.MouseClick("left", true)
```

### <h3 id="MoveClick">.MoveClick(x, y, button, double)</h3>

    移动并点击鼠标

#### 参数:
    x,
    y,

    button (optional) - Accepts "left", "right", or "center". Defaults to left.
    double (optional) - Set to true to perform a double click. Defaults to false.

#### 示例:

```Go
robotgo.MoveClick(10, 20)
robotgo.MoveClick(10, 20, "left", true)
```

### <h3 id="MouseToggle">.MouseToggle(down, button)</h3>
    鼠标切换

    Toggles mouse button.

#### 参数:

    down (optional) - Accepts down or up. Defaults to down.
    button (optional) - Accepts "left", "right", or "center". Defaults to left.

#### 示例:

```Go
robotgo.MouseToggle("down")
robotgo.MouseToggle("down", "right")
```

### <h3 id="DragMouse">.DragMouse(x, y)</h3>
    拖动鼠标

    Moves mouse to x, y instantly, with the mouse button held down.

#### 参数:

    x, y

#### 示例:

```Go
// Mouse down at 0, 0 and then drag to 100, 100 and release. 
robotgo.MoveMouse(0, 0)
robotgo.MouseToggle("down")
robotgo.DragMouse(100, 100)
robotgo.MouseToggle("up")
```

### <h3 id="GetMousePos">.GetMousePos()</h3>
    获取鼠标的位置

    Gets the mouse coordinates.

#### 返回值:

    Returns an object with keys x and y.

#### 示例:

```Go
x, y := robotgo.GetMousePos()
fmt.Println("pos:", x, y)
```

### <h3 id="ScrollMouse">.ScrollMouse(magnitude, direction)</h3>
    滚动鼠标

    Scrolls the mouse either up or down.

#### 参数:
    滚动位置的大小
    滚动方向: up (向上滚动)  down (向下滚动)

    magnitude - The amount to scroll.
    direction - Accepts down or up.

#### 示例:

```Go
robotgo.ScrollMouse(50, "up")

robotgo.ScrollMouse(50, "down")
```


## <h2 id="Screen">屏幕</h2>
### <h3 id="GetPixelColor">.GetPixelColor(x, y)
    获取坐标为 x, y 位置处的颜色

    Gets the pixel color at x, y. This function is perfect for getting a pixel or two,  
    but if you'll be reading large portions of the screen use screen.capture.

#### 参数:

    x, y

#### 返回值:

    Returns the hex color code of the pixel at x, y.

### <h3 id="GetScreenSize">.GetScreenSize()</h3>
    获取屏幕大小

    Gets the screen width and height.

#### 返回值:

    Returns an object with .width and .height.

### <h3 id="CaptureScreen">.CaptureScreen</h3>
    // CaptureScreen
    获取部分或者全部屏幕
    Gets part or all of the screen.

    GoCaptureScreen Returns a go struct


#### 参数:

    x (optional)
    y (optional)
    height (optional)
    width (optional)
    If no arguments are provided, capturescreen(screencapture) will get the full screen.

#### 返回值:

    返回一个 bitmap object.

## <h2 id="Bitmap">位图</h2>

    This is a work in progress.

### <h3 id="FindBitmap">.FindBitmap</h3>

    查找 bitmap.

#### 参数:

    bitmap;
    rect (可选参数): x, y, w, h

#### Return:

    查找到, 返回 bitmap 的 x 和y 坐标; 没有返回 nil


### <h3 id="OpenBitmap">.OpenBitmap</h3>

    打开 bitmap 图片.

#### 参数:

    bitmap 图片路径,
    MMImageType (可选)

#### 返回值:

     返回一个 bitmap 对象

### <h3 id="SaveBitmap">.SaveBitmap</h3>

    保存一个 bitmap 图片.

#### 参数:

    bitmap 对象,
    保存路径,
    imagetype (int) 

#### 返回值:

    保存图片, 返回保存状态


### <h3 id="TostringBitmap">.TostringBitmap</h3>

     将一个 bitmap 对象转换为字符串对象.

#### 参数:

    bitmap 对象 

#### Return:

    返回一个 bitmap 字符串 

### <h3 id="GetPortion">.GetPortion</h3>

     bitmap from a portion

#### 参数:

    bitmap,
    rect: x, y, w, h 

#### 返回值:

    Returns new bitmap object created from a portion of another    

### <h3 id="Convert">.Convert(openpath, savepath, MMImageType)</h3>

    转换 bitmap 图片格式

#### 参数:

    openpath,
    savepath,
    MMImageType (可选)

#### 示例:

```Go
robotgo.Convert("test.png", "test.tif")
```  

### <h3 id="FreeBitmap">.FreeBitmap(MMBitmapRef)</h3>

    FreeBitmap free and dealloc bitmap

#### 参数:

    MMBitmapRef

#### 示例:

```Go
robotgo.FreeBitmap(bitmap)
```    


### <h3 id="ReadBitmap">.ReadBitmap(MMBitmapRef)</h3>

    ReadBitmap returns false and sets error if |bitmap| is NULL

#### 参数:

    MMBitmapRef

#### 返回值:

    bool
    
#### 示例:

```Go
robotgo.ReadBitmap(bitmap)
```    


### <h3 id="CopyBitpb">.CopyBitpb(MMBitmapRef)</h3>

   CopyBitpb copy bitmap to pasteboard

#### 参数:

    MMBitmapRef

#### 返回值:

    bool

#### 示例:

```Go
robotgo.CopyBitpb(bitmap)
```    

### <h3 id="DeepCopyBit">.DeepCopyBit(MMBitmapRef)</h3>

   DeepCopyBit deep copy bitmap

#### 参数:

    MMBitmapRef

#### 返回值:

    MMBitmapRef

#### 示例:

```Go
robotgo.DeepCopyBit(bitmap)
```  

## <h2 id="Event">事件</h2> 

### <h3 id="AddEvent">.AddEvent(string)</h3>

    监听全局事件

#### 参数:

    string

    (鼠标参数: mleft, mright, wheelDown, wheelUp, wheelLeft, wheelRight)
 
#### 返回值:

    监听成功返回 0

#### 示例:

```Go
package main

import (
    "fmt"

    "github.com/go-vgo/robotgo"
)

func main() {
  keve := robotgo.AddEvent("k")
  if keve {
    fmt.Println("you press...", "k")
  }

  mleft := robotgo.AddEvent("mleft")
  if mleft {
    fmt.Println("you press...", "mouse left button")
  }
} 
```

### <h3 id="StopEvent">.StopEvent()</h3>  
    停止事件监听

## <h2 id="Window">窗口</h2> 

### <h3 id="ShowAlert">.ShowAlert(title, msg, defaultButton, cancelButton string)</h3>

    Displays alert with the given attributes. If cancelButton is not given, only the defaultButton is displayed

#### 参数:

    title (string),
    msg (string),
    defaultButton (optional string),
    cancelButton (optional string)
           

#### 返回值:

    Returns 0 (True) if the default button was pressed, or 1 (False) if cancelled.
   
### <h3 id="CloseWindow">.CloseWindow()</h3>

    关闭窗口

#### 参数:
    无    

#### 返回值:
    无

### <h3 id="IsValid">.IsValid()</h3>

    Valid the Window

#### 参数:
    无      

#### 返回值:
    如果窗口 selected 返回 true 


### <h3 id="SetActive">.SetActive()</h3>

    设为当前窗口

#### 参数:
    hwnd  

#### 返回值:
    void


### <h3 id="GetActive">.GetActive()</h3>

    获取当前窗口

#### 参数:
    无       

#### 返回值:
    Returns hwnd

### <h3 id="SetHandle">.SetHandle()</h3>

    Set the Window Handle

#### 参数:
    int 

#### 返回值:
    bool    

### <h3 id="GetHandle">.GetHandle()</h3>

    获取窗口 Handle

#### 参数:
    无    

#### 返回值:
    Returns hwnd  

### <h3 id="GetTitle">.GetTitle()</h3>

    获取窗口标题

#### 参数:
           

#### 返回值:
    返回窗口标题  

### <h3 id="GetPID">.GetPID()</h3>

    获取进程 id

#### 参数:
    无   

#### 返回值:
    返回进程 id    

### <h3 id="Pids">.Pids()</h3>

    获取所有进程 id

#### 参数:
    无   

#### 返回值:
    返回进程 id   

### <h3 id="PidExists">.PidExists()</h3>

    判断进程 id 是否存在

#### 参数:
    pid  

#### 返回值:
    返回 bool 

### <h3 id="Process">.Process()</h3>

  Process get the all process struct

#### 参数:
    无  

#### 返回值:
    Returns []Nps, error

### <h3 id="FindName">.FindName()</h3>

    FindName find the process name by the process id

#### 参数:
    pid  

#### 返回值:
    Returns string, error 

### <h3 id="FindNames">.FindNames()</h3>

    FindNames find the all process name

#### Arguments:
    none  

#### Return:
    Returns []string, error  

### <h3 id="FindIds">.FindIds()</h3>

    FindIds find the process id by the process name

#### Arguments:
    name string  

#### Return:
    Returns []int32, error  

### <h3 id="ActivePID">.ActivePID()</h3>

    ActivePID window active by PID

#### Arguments:
    pid int32 

#### Return:
    none

---

--- METRICS ---
- Files Extracted: 10
- Estimated Token Budget: ~21765 tokens
- Canonical Reference: https://codewiki.google/github.com/go-vgo/robotgo
