{"id":13366533,"url":"https://github.com/Go-vGo/robotGo","last_synced_at":"2025-03-12T18:31:08.632Z","repository":{"id":37394968,"uuid":"69269563","full_name":"go-vgo/robotgo","owner":"go-vgo","description":"RobotGo, Go Native cross-platform RPA and GUI automation  @vcaesar","archived":false,"fork":false,"pushed_at":"2024-10-07T21:18:13.000Z","size":5977,"stargazers_count":9618,"open_issues_count":176,"forks_count":881,"subscribers_count":245,"default_branch":"master","last_synced_at":"2024-10-14T21:41:48.047Z","etag":null,"topics":["automation","c","go","golang","hook","image","mouse","opencv","robot","robotgo","rpa","window"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/go-vgo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-26T16:26:56.000Z","updated_at":"2024-10-14T17:49:43.000Z","dependencies_parsed_at":"2023-02-14T02:10:17.408Z","dependency_job_id":"8f557297-bd8b-4ee6-8920-2aad4654bae9","html_url":"https://github.com/go-vgo/robotgo","commit_stats":{"total_commits":1309,"total_committers":25,"mean_commits":52.36,"dds":"0.025210084033613467","last_synced_commit":"6c137427dbe77491a2e12b6023d837e81df588ec"},"previous_names":[],"tags_count":66,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-vgo%2Frobotgo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-vgo%2Frobotgo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-vgo%2Frobotgo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-vgo%2Frobotgo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/go-vgo","download_url":"https://codeload.github.com/go-vgo/robotgo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221309833,"owners_count":16795819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","c","go","golang","hook","image","mouse","opencv","robot","robotgo","rpa","window"],"created_at":"2024-07-30T00:01:26.470Z","updated_at":"2025-03-12T18:31:08.625Z","avatar_url":"https://github.com/go-vgo.png","language":"Go","readme":"# Robotgo\n\n\u003c!--\u003cimg align=\"right\" src=\"https://raw.githubusercontent.com/go-vgo/robotgo/master/logo.jpg\"\u003e--\u003e\n\u003c!--[![Build Status](https://travis-ci.org/go-vgo/robotgo.svg)](https://travis-ci.org/go-vgo/robotgo)\n[![codecov](https://codecov.io/gh/go-vgo/robotgo/branch/master/graph/badge.svg)](https://codecov.io/gh/go-vgo/robotgo)--\u003e\n\u003c!--\u003ca href=\"https://circleci.com/gh/go-vgo/robotgo/tree/dev\"\u003e\u003cimg src=\"https://img.shields.io/circleci/project/go-vgo/robotgo/dev.svg\" alt=\"Build Status\"\u003e\u003c/a\u003e--\u003e\n\n[![Build Status](https://github.com/go-vgo/robotgo/workflows/Go/badge.svg)](https://github.com/go-vgo/robotgo/commits/master)\n[![CircleCI Status](https://circleci.com/gh/go-vgo/robotgo.svg?style=shield)](https://circleci.com/gh/go-vgo/robotgo)\n[![Build Status](https://travis-ci.org/go-vgo/robotgo.svg)](https://travis-ci.org/go-vgo/robotgo)\n![Appveyor](https://ci.appveyor.com/api/projects/status/github/go-vgo/robotgo?branch=master\u0026svg=true)\n[![Go Report Card](https://goreportcard.com/badge/github.com/go-vgo/robotgo)](https://goreportcard.com/report/github.com/go-vgo/robotgo)\n[![GoDoc](https://pkg.go.dev/badge/github.com/go-vgo/robotgo?status.svg)](https://pkg.go.dev/github.com/go-vgo/robotgo?tab=doc)\n[![GitHub release](https://img.shields.io/github/release/go-vgo/robotgo.svg)](https://github.com/go-vgo/robotgo/releases/latest)\n[![Join the chat at https://gitter.im/go-vgo/robotgo](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/go-vgo/robotgo?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n\u003c!-- [![Release](https://github-release-version.herokuapp.com/github/go-vgo/robotgo/release.svg?style=flat)](https://github.com/go-vgo/robotgo/releases/latest) --\u003e\n\u003c!-- \u003ca href=\"https://github.com/go-vgo/robotgo/releases\"\u003e\u003cimg src=\"https://img.shields.io/badge/%20version%20-%206.0.0%20-blue.svg?style=flat-square\" alt=\"Releases\"\u003e\u003c/a\u003e --\u003e\n\n\u003e Golang Desktop Automation. Control the mouse, keyboard, read the screen, process, Window Handle, image and bitmap and global event listener.\n\nRobotGo supports Mac, Windows, and Linux(X11); and robotgo supports arm64 and x86-amd64.\n\n## Contents\n\n- [Docs](#docs)\n- [Binding](#binding)\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Update](#update)\n- [Examples](#examples)\n- [Type Conversion and keys](https://github.com/go-vgo/robotgo/blob/master/docs/keys.md)\n- [Cross-Compiling](https://github.com/go-vgo/robotgo/blob/master/docs/install.md#crosscompiling)\n- [Authors](#authors)\n- [Plans](#plans)\n- [Donate](#donate)\n- [Contributors](#contributors)\n- [License](#license)\n\n## Docs\n\n- [GoDoc](https://godoc.org/github.com/go-vgo/robotgo) \u003cbr\u003e\n- [API Docs](https://github.com/go-vgo/robotgo/blob/master/docs/doc.md) (Deprecated, no updated)\n\n## Binding:\n\n[ADB](https://github.com/vcaesar/adb), packaging android adb API.\n\n[Robotn](https://github.com/vcaesar/robotn), binding JavaScript and other, support more language.\n\n## Requirements:\n\nNow, Please make sure `Golang, GCC` is installed correctly before installing RobotGo.\n\n### ALL:\n\n```\nGolang\n\nGCC\n```\n\n#### For MacOS:\n\nXcode Command Line Tools (And Privacy setting: [#277](https://github.com/go-vgo/robotgo/issues/277))\n\n```\nxcode-select --install\n```\n\n#### For Windows:\n\n[MinGW-w64](https://sourceforge.net/projects/mingw-w64/files) (Use recommended) or others Mingw [llvm-mingw](https://github.com/mstorsjo/llvm-mingw);\n\nDownload the Mingw, then set system environment variables `C:\\mingw64\\bin` to the Path.\n[Set environment variables to run GCC from command line](https://www.youtube.com/results?search_query=Set+environment+variables+to+run+GCC+from+command+line).\n\n`Or the other GCC` (But you should compile the \"libpng\" with yourself when use the [bitmap](https://github.com/vcaesar/bitmap).)\n\n#### For everything else:\n\n```\nGCC\n\nX11 with the XTest extension (the Xtst library)\n\n\"Clipboard\": xsel xclip\n\n\n\"Bitmap\": libpng (Just used by the \"bitmap\".)\n\n\"Event-Gohook\": xcb, xkb, libxkbcommon (Just used by the \"hook\".)\n\n```\n\n##### Ubuntu:\n\n```yml\n# gcc\nsudo apt install gcc libc6-dev\n\n# x11\nsudo apt install libx11-dev xorg-dev libxtst-dev\n\n# Clipboard\nsudo apt install xsel xclip\n\n#\n# Bitmap\nsudo apt install libpng++-dev\n\n# GoHook\nsudo apt install xcb libxcb-xkb-dev x11-xkb-utils libx11-xcb-dev libxkbcommon-x11-dev libxkbcommon-dev\n\n```\n\n##### Fedora:\n\n```yml\n# x11\nsudo dnf install libXtst-devel\n\n# Clipboard\nsudo dnf install xsel xclip\n\n#\n# Bitmap\nsudo dnf install libpng-devel\n\n# GoHook\nsudo dnf install libxkbcommon-devel libxkbcommon-x11-devel xorg-x11-xkb-utils-devel\n\n```\n\n## Installation:\n\nWith Go module support (Go 1.11+), just import:\n\n```go\nimport \"github.com/go-vgo/robotgo\"\n```\n\nOtherwise, to install the robotgo package, run the command:\n\n```\ngo get github.com/go-vgo/robotgo\n```\n\npng.h: No such file or directory? Please see [issues/47](https://github.com/go-vgo/robotgo/issues/47).\n\n## Update:\n\n```\ngo get -u github.com/go-vgo/robotgo\n```\n\nNote go1.10.x C file compilation cache problem, [golang #24355](https://github.com/golang/go/issues/24355).\n`go mod vendor` problem, [golang #26366](https://github.com/golang/go/issues/26366).\n\n## [Examples:](https://github.com/go-vgo/robotgo/blob/master/examples)\n\n#### [Mouse](https://github.com/go-vgo/robotgo/blob/master/examples/mouse/main.go)\n\n```Go\npackage main\n\nimport (\n  \"github.com/go-vgo/robotgo\"\n)\n\nfunc main() {\n  robotgo.MouseSleep = 100\n\n  robotgo.ScrollDir(10, \"up\")\n  robotgo.ScrollDir(20, \"right\")\n\n  robotgo.Scroll(0, -10)\n  robotgo.Scroll(100, 0)\n\n  robotgo.MilliSleep(100)\n  robotgo.ScrollSmooth(-10, 6)\n  // robotgo.ScrollRelative(10, -100)\n\n  robotgo.Move(10, 20)\n  robotgo.MoveRelative(0, -10)\n  robotgo.DragSmooth(10, 10)\n\n  robotgo.Click(\"wheelRight\")\n  robotgo.Click(\"left\", true)\n  robotgo.MoveSmooth(100, 200, 1.0, 10.0)\n\n  robotgo.Toggle(\"left\")\n  robotgo.Toggle(\"left\", \"up\")\n}\n```\n\n#### [Keyboard](https://github.com/go-vgo/robotgo/blob/master/examples/key/main.go)\n\n```Go\npackage main\n\nimport (\n  \"fmt\"\n\n  \"github.com/go-vgo/robotgo\"\n)\n\nfunc main() {\n  robotgo.TypeStr(\"Hello World\")\n  robotgo.TypeStr(\"だんしゃり\", 0, 1)\n  // robotgo.TypeStr(\"テストする\")\n\n  robotgo.TypeStr(\"Hi, Seattle space needle, Golden gate bridge, One world trade center.\")\n  robotgo.TypeStr(\"Hi galaxy, hi stars, hi MT.Rainier, hi sea. こんにちは世界.\")\n  robotgo.Sleep(1)\n\n  // ustr := uint32(robotgo.CharCodeAt(\"Test\", 0))\n  // robotgo.UnicodeType(ustr)\n\n  robotgo.KeySleep = 100\n  robotgo.KeyTap(\"enter\")\n  // robotgo.TypeStr(\"en\")\n  robotgo.KeyTap(\"i\", \"alt\", \"cmd\")\n\n  arr := []string{\"alt\", \"cmd\"}\n  robotgo.KeyTap(\"i\", arr)\n\n  robotgo.MilliSleep(100)\n  robotgo.KeyToggle(\"a\")\n  robotgo.KeyToggle(\"a\", \"up\")\n\n  robotgo.WriteAll(\"Test\")\n  text, err := robotgo.ReadAll()\n  if err == nil {\n    fmt.Println(text)\n  }\n}\n```\n\n#### [Screen](https://github.com/go-vgo/robotgo/blob/master/examples/screen/main.go)\n\n```Go\npackage main\n\nimport (\n  \"fmt\"\n  \"strconv\"\n\n  \"github.com/go-vgo/robotgo\"\n  \"github.com/vcaesar/imgo\"\n)\n\nfunc main() {\n  x, y := robotgo.Location()\n  fmt.Println(\"pos: \", x, y)\n\n  color := robotgo.GetPixelColor(100, 200)\n  fmt.Println(\"color---- \", color)\n\n  sx, sy := robotgo.GetScreenSize()\n  fmt.Println(\"get screen size: \", sx, sy)\n\n  bit := robotgo.CaptureScreen(10, 10, 30, 30)\n  defer robotgo.FreeBitmap(bit)\n\n  img := robotgo.ToImage(bit)\n  imgo.Save(\"test.png\", img)\n\n  num := robotgo.DisplaysNum()\n  for i := 0; i \u003c num; i++ {\n    robotgo.DisplayID = i\n    img1, _ := robotgo.CaptureImg()\n    path1 := \"save_\" + strconv.Itoa(i)\n    robotgo.Save(img1, path1+\".png\")\n    robotgo.SaveJpeg(img1, path1+\".jpeg\", 50)\n\n    img2, _ := robotgo.CaptureImg(10, 10, 20, 20)\n    robotgo.Save(img2, \"test_\"+strconv.Itoa(i)+\".png\")\n\n    x, y, w, h := robotgo.GetDisplayBounds(i)\n    img3, err := robotgo.CaptureImg(x, y, w, h)\n    fmt.Println(\"Capture error: \", err)\n    robotgo.Save(img3, path1+\"_1.png\")\n  }\n}\n```\n\n#### [Bitmap](https://github.com/vcaesar/bitmap/blob/main/examples/main.go)\n\n```Go\npackage main\n\nimport (\n  \"fmt\"\n\n  \"github.com/go-vgo/robotgo\"\n  \"github.com/vcaesar/bitmap\"\n)\n\nfunc main() {\n  bit := robotgo.CaptureScreen(10, 20, 30, 40)\n  // use `defer robotgo.FreeBitmap(bit)` to free the bitmap\n  defer robotgo.FreeBitmap(bit)\n\n  fmt.Println(\"bitmap...\", bit)\n  img := robotgo.ToImage(bit)\n  // robotgo.SavePng(img, \"test_1.png\")\n  robotgo.Save(img, \"test_1.png\")\n\n  bit2 := robotgo.ToCBitmap(robotgo.ImgToBitmap(img))\n  fx, fy := bitmap.Find(bit2)\n  fmt.Println(\"FindBitmap------ \", fx, fy)\n  robotgo.Move(fx, fy)\n\n  arr := bitmap.FindAll(bit2)\n  fmt.Println(\"Find all bitmap: \", arr)\n\n  fx, fy = bitmap.Find(bit)\n  fmt.Println(\"FindBitmap------ \", fx, fy)\n\n  bitmap.Save(bit, \"test.png\")\n}\n```\n\n#### [OpenCV](https://github.com/vcaesar/gcv)\n\n```Go\npackage main\n\nimport (\n  \"fmt\"\n  \"math/rand\"\n\n  \"github.com/go-vgo/robotgo\"\n  \"github.com/vcaesar/gcv\"\n  \"github.com/vcaesar/bitmap\"\n)\n\nfunc main() {\n  opencv()\n}\n\nfunc opencv() {\n  name := \"test.png\"\n  name1 := \"test_001.png\"\n  robotgo.SaveCapture(name1, 10, 10, 30, 30)\n  robotgo.SaveCapture(name)\n\n  fmt.Print(\"gcv find image: \")\n  fmt.Println(gcv.FindImgFile(name1, name))\n  fmt.Println(gcv.FindAllImgFile(name1, name))\n\n  bit := bitmap.Open(name1)\n  defer robotgo.FreeBitmap(bit)\n  fmt.Print(\"find bitmap: \")\n  fmt.Println(bitmap.Find(bit))\n\n  // bit0 := robotgo.CaptureScreen()\n  // img := robotgo.ToImage(bit0)\n  // bit1 := robotgo.CaptureScreen(10, 10, 30, 30)\n  // img1 := robotgo.ToImage(bit1)\n  // defer robotgo.FreeBitmapArr(bit0, bit1)\n  img, _ := robotgo.CaptureImg()\n  img1, _ := robotgo.CaptureImg(10, 10, 30, 30)\n\n  fmt.Print(\"gcv find image: \")\n  fmt.Println(gcv.FindImg(img1, img))\n  fmt.Println()\n\n  res := gcv.FindAllImg(img1, img)\n  fmt.Println(res[0].TopLeft.Y, res[0].Rects.TopLeft.X, res)\n  x, y := res[0].TopLeft.X, res[0].TopLeft.Y\n  robotgo.Move(x, y-rand.Intn(5))\n  robotgo.MilliSleep(100)\n  robotgo.Click()\n\n  res = gcv.FindAll(img1, img) // use find template and sift\n  fmt.Println(\"find all: \", res)\n  res1 := gcv.Find(img1, img)\n  fmt.Println(\"find: \", res1)\n\n  img2, _, _ := robotgo.DecodeImg(\"test_001.png\")\n  x, y = gcv.FindX(img2, img)\n  fmt.Println(x, y)\n}\n```\n\n#### [Event](https://github.com/robotn/gohook/blob/master/examples/main.go)\n\n```Go\npackage main\n\nimport (\n  \"fmt\"\n\n  // \"github.com/go-vgo/robotgo\"\n  hook \"github.com/robotn/gohook\"\n)\n\nfunc main() {\n  add()\n  low()\n  event()\n}\n\nfunc add() {\n  fmt.Println(\"--- Please press ctrl + shift + q to stop hook ---\")\n  hook.Register(hook.KeyDown, []string{\"q\", \"ctrl\", \"shift\"}, func(e hook.Event) {\n    fmt.Println(\"ctrl-shift-q\")\n    hook.End()\n  })\n\n  fmt.Println(\"--- Please press w---\")\n  hook.Register(hook.KeyDown, []string{\"w\"}, func(e hook.Event) {\n    fmt.Println(\"w\")\n  })\n\n  s := hook.Start()\n  \u003c-hook.Process(s)\n}\n\nfunc low() {\n\tevChan := hook.Start()\n\tdefer hook.End()\n\n\tfor ev := range evChan {\n\t\tfmt.Println(\"hook: \", ev)\n\t}\n}\n\nfunc event() {\n  ok := hook.AddEvents(\"q\", \"ctrl\", \"shift\")\n  if ok {\n    fmt.Println(\"add events...\")\n  }\n\n  keve := hook.AddEvent(\"k\")\n  if keve {\n    fmt.Println(\"you press... \", \"k\")\n  }\n\n  mleft := hook.AddEvent(\"mleft\")\n  if mleft {\n    fmt.Println(\"you press... \", \"mouse left button\")\n  }\n}\n```\n\n#### [Window](https://github.com/go-vgo/robotgo/blob/master/examples/window/main.go)\n\n```Go\npackage main\n\nimport (\n  \"fmt\"\n\n  \"github.com/go-vgo/robotgo\"\n)\n\nfunc main() {\n  fpid, err := robotgo.FindIds(\"Google\")\n  if err == nil {\n    fmt.Println(\"pids... \", fpid)\n\n    if len(fpid) \u003e 0 {\n      robotgo.TypeStr(\"Hi galaxy!\", fpid[0])\n      robotgo.KeyTap(\"a\", fpid[0], \"cmd\")\n\n      robotgo.KeyToggle(\"a\", fpid[0])\n      robotgo.KeyToggle(\"a\", fpid[0], \"up\")\n\n      robotgo.ActivePid(fpid[0])\n\n      robotgo.Kill(fpid[0])\n    }\n  }\n\n  robotgo.ActiveName(\"chrome\")\n\n  isExist, err := robotgo.PidExists(100)\n  if err == nil \u0026\u0026 isExist {\n    fmt.Println(\"pid exists is\", isExist)\n\n    robotgo.Kill(100)\n  }\n\n  abool := robotgo.Alert(\"test\", \"robotgo\")\n  if abool {\n \t  fmt.Println(\"ok@@@ \", \"ok\")\n  }\n\n  title := robotgo.GetTitle()\n  fmt.Println(\"title@@@ \", title)\n}\n```\n\n## Authors\n\n- [The author is vz](https://github.com/vcaesar)\n- [Maintainers](https://github.com/orgs/go-vgo/people)\n- [Contributors](https://github.com/go-vgo/robotgo/graphs/contributors)\n\n## Plans\n\n- Refactor some C code to Go (such as x11, windows)\n- Better multiscreen support\n- Wayland support\n- Update Window Handle\n- Try to support Android and IOS\n\n## Contributors\n\n- See [contributors page](https://github.com/go-vgo/robotgo/graphs/contributors) for full list of contributors.\n- See [Contribution Guidelines](https://github.com/go-vgo/robotgo/blob/master/CONTRIBUTING.md).\n\n## License\n\nRobotgo 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.\n\nSee [LICENSE-APACHE](http://www.apache.org/licenses/LICENSE-2.0), [LICENSE-MIT](https://github.com/go-vgo/robotgo/blob/master/LICENSE).\n","funding_links":[],"categories":["GUI"],"sub_categories":["高级控制台界面","高級控制台界面"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGo-vGo%2FrobotGo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGo-vGo%2FrobotGo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGo-vGo%2FrobotGo/lists"}