Showing preview only (322K chars total). Download the full file or copy to clipboard to get everything.
Repository: go-vgo/robotgo
Branch: master
Commit: 7dee03f3f83b
Files: 99
Total size: 300.2 KB
Directory structure:
gitextract_108ox7j1/
├── .circleci/
│ ├── config.yml
│ └── images/
│ └── primary/
│ └── Dockerfile
├── .github/
│ ├── CODEOWNERS
│ ├── CONTRIBUTING.md
│ ├── issue_template.md
│ ├── pull_request_template.md
│ └── workflows/
│ └── go.yml
├── .gitignore
├── .travis.yml
├── CLA.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── appveyor.yml
├── base/
│ ├── LICENSE
│ ├── MMBitmap.h
│ ├── base.go
│ ├── bitmap_free_c.h
│ ├── deadbeef_rand.h
│ ├── deadbeef_rand_c.h
│ ├── inline_keywords.h
│ ├── microsleep.h
│ ├── os.h
│ ├── pubs.h
│ ├── rgb.h
│ ├── types.h
│ └── xdisplay_c.h
├── clipboard/
│ ├── README.md
│ ├── clipboard.go
│ ├── clipboard_darwin.go
│ ├── clipboard_test.go
│ ├── clipboard_unix.go
│ ├── clipboard_windows.go
│ ├── cmd/
│ │ ├── gocopy/
│ │ │ └── gocopy.go
│ │ └── gopaste/
│ │ └── gopaste.go
│ └── example/
│ └── example.go
├── cv/
│ ├── README.md
│ └── gocv.go
├── doc.go
├── docs/
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── archive/
│ │ ├── README_zh.md
│ │ ├── doc.md
│ │ └── doc_zh.md
│ ├── install.md
│ └── keys.md
├── event/
│ ├── android/
│ │ └── event_c.h
│ └── ios/
│ └── event_c.h
├── examples/
│ ├── README.md
│ ├── key/
│ │ └── main.go
│ ├── main.go
│ ├── mouse/
│ │ └── main.go
│ ├── scale/
│ │ └── main.go
│ ├── screen/
│ │ └── main.go
│ └── window/
│ └── main.go
├── go.mod
├── go.sum
├── img.go
├── key/
│ ├── key.go
│ ├── key_windows.go
│ ├── keycode.h
│ ├── keycode_c.h
│ ├── keypress.h
│ └── keypress_c.h
├── key.go
├── keycode.go
├── mouse/
│ ├── mouse.go
│ ├── mouse.h
│ ├── mouse_c.h
│ ├── mouse_darwin.go
│ ├── mouse_windows.go
│ └── mouse_x11.go
├── ps.go
├── robot_info_test.go
├── robotgo.go
├── robotgo_adb.go
├── robotgo_android.go
├── robotgo_fn_v1.go
├── robotgo_mac.go
├── robotgo_mac_unix.go
├── robotgo_mac_win.go
├── robotgo_ocr.go
├── robotgo_test.go
├── robotgo_win.go
├── robotgo_x11.go
├── screen/
│ ├── goScreen.h
│ ├── screen.go
│ ├── screen_c.h
│ └── screengrab_c.h
├── screen.go
├── test/
│ └── index.html
├── wayland_n.go
├── window/
│ ├── alert_c.h
│ ├── goWindow.h
│ ├── pub.h
│ ├── win_sys.h
│ ├── window.go
│ └── window.h
└── windows_n.go
================================================
FILE CONTENTS
================================================
================================================
FILE: .circleci/config.yml
================================================
version: 2
jobs:
build:
docker:
# using custom image, see .circleci/images/primary/Dockerfile
# - image: govgo/robotgoci:1.10.3
- image: golang:1.25.0
working_directory: /gopath/src/github.com/go-vgo/robotgo
steps:
- checkout
# specify any bash command here prefixed with `run: `
- run: apt update
- run:
apt -y install gcc libc6-dev
libx11-dev xorg-dev libxtst-dev
xsel xclip
# libpng++-dev
# xcb libxcb-xkb-dev x11-xkb-utils libx11-xcb-dev libxkbcommon-x11-dev libxkbcommon-dev
- run: apt -y install xvfb
#
# override:
- run: go get -v -t -d ./...
- run: xvfb-run go test -v ./...
#
# codecov.io
# - run: xvfb-run go test -v -covermode=count -coverprofile=coverage.out
# - run: bash <(curl -s https://codecov.io/bash)
================================================
FILE: .circleci/images/primary/Dockerfile
================================================
# FROM golang:1.10.1
FROM golang:1.24.2-stretch AS build
# FROM govgo/go:1.11.1
RUN apt update && apt install -y --no-install-recommends \
# customize dependencies
libx11-dev xorg-dev \
libxtst-dev \
# Bitmap
libpng++-dev \
# Event:
xcb libxcb-xkb-dev \
x11-xkb-utils libx11-xcb-dev \
libxkbcommon-x11-dev libxkbcommon-dev \
# Clipboard:
xsel xclip && \
#
apt remove --purge --auto-remove && \
apt clean && \
rm -rf /var/lib/apt/lists/*
RUN go get -u github.com/go-vgo/robotgo
================================================
FILE: .github/CODEOWNERS
================================================
# general
* @vcaesar
================================================
FILE: .github/CONTRIBUTING.md
================================================
# Contributing to Robotgo
================================================
FILE: .github/issue_template.md
================================================
1. Please **speak English (English only)**, this is the language everybody of us can speak and write.
2. Please take a moment to **search** that an issue **doesn't already exist**.
3. Please make sure `Golang, GCC` is installed correctly before installing RobotGo.
<!-- 4. Please ask questions or config/deploy problems on our Gitter channel: https://gitter.im/go-vgo/robotgo -->
4. Please give all relevant information below for bug reports, incomplete details will be handled as an invalid report.
**You MUST delete the content above including this line before posting, otherwise your issue will be invalid.**
- Robotgo version (or commit ref):
- Go version:
- Gcc version:
- Operating system and bit:
- Resolution:
- Can you reproduce the bug at [Examples](https://github.com/go-vgo/robotgo/blob/master/examples/):
- [ ] Yes (provide example code)
- [ ] No
- [ ] Not relevant
- Provide example code:
```Go
```
- Log gist:
## Description
...
================================================
FILE: .github/pull_request_template.md
================================================
The pull request will be closed without any reasons if it does not satisfy any of following requirements:
1. Make sure you are targeting the `master` branch, pull requests on release branches are only allowed for bug fixes.
2. Add new features, please provide the reasons and test code.
3. Please read contributing guidelines: [CONTRIBUTING](https://github.com/go-vgo/robotgo/blob/master/CONTRIBUTING.md) and sign the CLA.
4. Describe what your pull request does and which issue you're targeting (if any and **Please use English**)
5. ... if it is not related to any particular issues, explain why we should not reject your pull request.
6. The Commits must **use English**, must be test and No useless submissions.
**You MUST delete the content above including this line before posting, otherwise your pull request will be invalid.**
**Please provide Issues links to:**
- Issues: #1
**Provide test code:**
```Go
```
## Description
...
================================================
FILE: .github/workflows/go.yml
================================================
name: Go
on: [push]
jobs:
test:
# name: build
strategy:
matrix:
# go: [1.12.x, 1.13.x]
os: [macOS-latest, windows-latest] # ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- name: Set up Go 1.26.0
uses: actions/setup-go@v6
with:
go-version: 1.26.x
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v6
- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Build
run: go build -v .
- name: Test
run: go test -v robot_info_test.go
# run: go test -v .
================================================
FILE: .gitignore
================================================
# Object files
.DS_Store
.vscode
.idea
robot_test.png
# Examples
examples/screen/screen
examples/screen/saveCapture.png
#
examples/bitmap/test.png
examples/bitmap/test2.png
examples/bitmap/test.tif
examples/bitmap/test31.tif
examples/bitmap/tocbitmap.png
examples/bitmap/teststr.png
test/test.png
# Debug files
*.dSYM/
*.su
debug
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.o
*.ko
*.obj
*.elf
# Precompiled Headers
*.gch
*.pch
#
cdeps/hook
event/hook
vendor
# Libraries
*.lib
# !cdeps/win32/libpng.lib
# !cdeps/win32/zlib.lib
# !cdeps/win64/libpng.lib
# !cdeps/win64/zlib.lib
# ##
*.a
!cdeps/mac/libpng.a
!cdeps/mac/amd/libpng.a
!cdeps/mac/m1/libpng.a
#
!cdeps/win32/libpng.a
!cdeps/win64/libpng.a
!cdeps/win/amd/win32/libpng.a
!cdeps/win/amd/win64/libpng.a
!cdeps/win/arm/libpng.a
#
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
.glide/
#
examples/bitmap/test_IMG.png
examples/bitmap/imgToBitmap/test_01.png
examples/bitmap/imgToBitmap/test_002.jpeg
examples/bitmap/imgToBitmap/test_003.jpeg
examples/bitmap/imgToBitmap/test_1.png
examples/bitmap/imgToBitmap/test_2.jpeg
examples/bitmap/imgToBitmap/test.png
examples/bitmap/imgToBitmap/test_7.jpeg
robot_img.png
examples/bitmap/bitmapTobytes/out.jpg
================================================
FILE: .travis.yml
================================================
language: go
os:
- linux
- osx
go:
# - 1.7.x
# - 1.8.x
# - 1.9.x
# - 1.10.x
# - 1.11.x
# - 1.12.x
# - 1.13.x
# - 1.14.x
# - 1.15.x
# - 1.16.x
# - 1.17.x
# - 1.18.x
- 1.19.x
# - tip
addons:
apt:
packages:
- libx11-dev xorg-dev
- libxtst-dev libpng++-dev
- xcb libxcb-xkb-dev x11-xkb-utils libx11-xcb-dev libxkbcommon-x11-dev
# - libusb-dev
- libxkbcommon-dev
- xsel
- xclip
#
- xvfb
# script:
# - sudo apt update
# - sudo apt install libx11-dev
# - sudo apt install xorg-dev
# - sudo apt install libxtst-dev libpng++-dev
# # Event:
# - sudo apt install xcb libxcb-xkb-dev x11-xkb-utils libx11-xcb-dev libxkbcommon-x11-dev
# - sudo apt install libxkbcommon-dev
# # Clipboard:
# - sudo apt install xsel
# - sudo apt install xclip
# - go test -v .
before_install:
- export PATH=$PATH:$HOME/gopath/bin
- go get -v -t -d ./...
script:
- if [ "${TRAVIS_OS_NAME}" = "linux" ]; then xvfb-run go test -v ./...; fi
- if [ "${TRAVIS_OS_NAME}" = "osx" ]; then go test -v ./...; fi
================================================
FILE: CLA.md
================================================
### AtomAI Individual Contributor License Agreement
Version: 2025-11-19 (https://cla-assistant.io/)
Thank you for your interest in contributing to open source software projects (“Projects”) made available by AtomAI SE or its affiliates (“AtomAI”). This Individual Contributor License Agreement (“Agreement”) sets out the terms governing any source code, object code, bug fixes, configuration changes, tools, specifications, documentation, data, materials, feedback, information or other works of authorship that you submit or have submitted, in any form and in any manner, to AtomAI in respect of any of the Projects (collectively “Contributions”). If you have any questions respecting this Agreement, please contact info@atomai.cc.
You agree that the following terms apply to all of your past, present and future Contributions. Except for the licenses granted in this Agreement, you retain all of your right, title and interest in and to your Contributions.
**Copyright License.** You hereby grant, and agree to grant, to AtomAI a non-exclusive, perpetual, irrevocable, worldwide, fully-paid, royalty-free, transferable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, and distribute your Contributions and such derivative works, with the right to sublicense the foregoing rights through multiple tiers of sublicensees.
**Patent License.** You hereby grant, and agree to grant, to AtomAI a non-exclusive, perpetual, irrevocable, worldwide, fully-paid, royalty-free, transferable patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer your Contributions, where such license applies only to those patent claims licensable by you that are necessarily infringed by your Contributions alone or by combination of your Contributions with the Project to which such Contributions were submitted, with the right to sublicense the foregoing rights through multiple tiers of sublicensees.
**Moral Rights.** To the fullest extent permitted under applicable law, you hereby waive, and agree not to assert, all of your “moral rights” in or relating to your Contributions for the benefit of AtomAI, its assigns, and their respective direct and indirect sublicensees.
**Third Party Content/Rights.** If your Contribution includes or is based on any source code, object code, bug fixes, configuration changes, tools, specifications, documentation, data, materials, feedback, information or other works of authorship that were not authored by you (“Third Party Content”) or if you are aware of any third party intellectual property or proprietary rights associated with your Contribution (“Third Party Rights”), then you agree to include with the submission of your Contribution full details respecting such Third Party Content and Third Party Rights, including, without limitation, identification of which aspects of your Contribution contain Third Party Content or are associated with Third Party Rights, the owner/author of the Third Party Content and Third Party Rights, where you obtained the Third Party Content, and any applicable third party license terms or restrictions respecting the Third Party Content and Third Party Rights. For greater certainty, the foregoing obligations respecting the identification of Third Party Content and Third Party Rights do not apply to any portion of a Project that is incorporated into your Contribution to that same Project.
**Representations.** You represent that, other than the Third Party Content and Third Party Rights identified by you in accordance with this Agreement, you are the sole author of your Contributions and are legally entitled to grant the foregoing licenses and waivers in respect of your Contributions. If your Contributions were created in the course of your employment with your past or present employer(s), you represent that such employer(s) has authorized you to make your Contributions on behalf of such employer(s) or such employer (s) has waived all of their right, title or interest in or to your Contributions.
**Disclaimer.** To the fullest extent permitted under applicable law, your Contributions are provided on an "asis" basis, without any warranties or conditions, express or implied, including, without limitation, any implied warranties or conditions of non-infringement, merchantability or fitness for a particular purpose. You are not required to provide support for your Contributions, except to the extent you desire to provide support.
**No Obligation.** You acknowledge that AtomAI is under no obligation to use or incorporate your Contributions into any of the Projects. The decision to use or incorporate your Contributions into any of the Projects will be made at the sole discretion of AtomAI or its authorized delegates.
**Disputes.** This Agreement shall be governed by and construed in accordance with the laws of the State of Wyoming, United States of America, without giving effect to its principles or rules regarding conflicts of laws, other than such principles directing application of Wyoming law. The parties hereby submit to venue in, and jurisdiction of the courts located in Wyoming, Wyoming for purposes relating to this Agreement.
In the event that any of the provisions of this Agreement shall be held by a court or other tribunal of competent jurisdiction to be unenforceable, the remaining portions hereof shall remain in full force and effect.
**Assignment.** You agree that AtomAI may assign this Agreement, and all of its rights, obligations and licenses hereunder.
================================================
FILE: CONTRIBUTING.md
================================================
# Contribution Guidelines
## Introduction
This document explains how to contribute changes to the Robotgo project. It assumes you have followed the README.md and [API Document](https://github.com/go-vgo/robotgo/blob/master/docs/doc.md).
Sensitive security-related issues should be reported to [info@atomai.cc](info@atomaicc).
<!-- [security@Robotgo.io](mailto:security@Robotgo.io.) -->
## Bug reports
Please search the issues on the issue tracker with a variety of keywords to ensure your bug is not already reported.
If unique, [open an issue](https://github.com/go-vgo/robotgo/issues/new) and answer the questions so we can understand and reproduce the problematic behavior.
The burden is on you to convince us that it is actually a bug in Robotgo. This is easiest to do when you write clear, concise instructions so we can reproduce the behavior (even if it seems obvious). The more detailed and specific you are, the faster we will be able to help you. Check out [How to Report Bugs Effectively](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html).
Please be kind, remember that Robotgo comes at no cost to you, and you're getting free help.
## Discuss your design
The project welcomes submissions but please let everyone know what you're working on if you want to change or add something to the Robotgo repositories.
Before starting to write something new for the Robotgo project, please [file an issue](https://github.com/go-vgo/robotgo/issues/new). Significant changes must go through the [change proposal process](https://github.com/go-vgo/proposals) before they can be accepted.
This process gives everyone a chance to validate the design, helps prevent duplication of effort, and ensures that the idea fits inside the goals for the project and tools. It also checks that the design is sound before code is written; the code review tool is not the place for high-level discussions.
## Testing redux
Before sending code out for review, run all the tests for the whole tree to make sure the changes don't break other usage and keep the compatibility on upgrade. You must be test on Mac, Windows, Linux and other. You should install the CLI for Circle CI, as we are using the server for continuous testing.
## Code review
In addition to the owner, Changes to Robotgo must be reviewed before they are accepted, no matter who makes the change even if it is a maintainer. We use GitHub's pull request workflow to do that and we also use [LGTM](http://lgtm.co) to ensure every PR is reviewed by vz or least 2 maintainers.
## Sign your work
The sign-off is a simple line at the end of the explanation for the patch. Your signature certifies that you wrote the patch or otherwise have the right to pass it on as an open-source patch.
## Maintainers
To make sure every PR is checked, we got team maintainers. A maintainer should be a contributor of Robotgo and contributed at least 4 accepted PRs.
## Owners
Since Robotgo is a pure community organization without any company support, Copyright 2016 The go-vgo Project Developers.
## Versions
Robotgo has the `master` branch as a tip branch and has version branches such as `v0.30.0`. `v0.40.0` is a release branch and we will tag `v0.40.0` for binary download. If `v0.40.0` has bugs, we will accept pull requests on the `v0.40.0` branch and publish a `v0.40.1` tag, after bringing the bug fix also to the master branch.
Since the `master` branch is a tip version, if you wish to use Robotgo in production, please download the latest release tag version. All the branches will be protected via GitHub, all the PRs to every branch must be reviewed by two maintainers and must pass the automatic tests.
## Copyright
Code that you contribute should use the standard copyright header:
```
// Copyright (c) 2016-2025 AtomAI, All rights reserved.
//
// See the COPYRIGHT file at the top-level directory of this distribution and at
// https://github.com/go-vgo/robotgo/blob/master/LICENSE
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0>
//
// This file may not be copied, modified, or distributed
// except according to those terms.
```
Files in the repository contain copyright from the year they are added to the year they are last changed. If the copyright author is changed, just paste the header below the old one.
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: README.md
================================================
# Robotgo
<!-- <img align="right" src="https://raw.githubusercontent.com/go-vgo/robotgo/master/logo.jpg"> -->
<!-- [](https://codecov.io/gh/go-vgo/robotgo) -->
[](https://github.com/go-vgo/robotgo/commits/master)
[](https://circleci.com/gh/go-vgo/robotgo)

[](https://goreportcard.com/report/github.com/go-vgo/robotgo)
[](https://pkg.go.dev/github.com/go-vgo/robotgo?tab=doc)
[](https://github.com/go-vgo/robotgo/releases/latest)
> 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 (X11); and robotgo supports arm64 and x86-amd64.
[RobotGo-Pro](https://github.com/vcaesar/robotgo-pro) get the JavaScript, Python, Lua and others version, tech supports, new features and newest robotgo version (such as Wayland support, "no open-source version forever").
## Contents
- [Docs](#docs)
- [Binding](#binding)
- [Requirements](#requirements)
- [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)
## Binding:
[ADB](https://github.com/vcaesar/adb), packaging android adb API.
## Requirements:
Now, Please make sure `Golang, GCC` is installed correctly before installing RobotGo.
### ALL:
```
Golang
GCC
```
#### For MacOS:
```
brew install go
```
Xcode Command Line Tools; <br>
And Privacy setting, add Screen Recording and Accessibility under: <br>
`System Settings > Privacy & Security > Accessibility, Screen & System Audio Recording`.
```
xcode-select --install
```
#### For Windows:
```
winget install Golang.go
```
[llvm-mingw](https://github.com/mstorsjo/llvm-mingw)
```
winget install MartinStorsjo.LLVM-MinGW.UCRT
```
or [Mingw-w64](https://sourceforge.net/projects/mingw-w64/files)
```
winget install BrechtSanders.WinLibs.POSIX.UCRT
```
Or Download the [Mingw-w64](https://sourceforge.net/projects/mingw-w64/files) and the others gcc, then set system environment variables like `C:\mingw64\bin` to the env `Path`.
[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).
`Or The others GCC` (Except the Mingw-w64, you should compile the "libpng" with yourself when use the [bitmap](https://github.com/vcaesar/bitmap).)
#### For everything else:
```
GCC
X11 with the XTest extension (the Xtst library)
"Clipboard": xsel xclip
"Bitmap": libpng (Just used by the "bitmap".)
"Event-Gohook": xcb, xkb, libxkbcommon (Just used by the "hook".)
```
##### Ubuntu:
```yml
# sudo apt install golang
sudo snap install go --classic
# gcc
sudo apt install gcc libc6-dev
# x11
sudo apt install libx11-dev xorg-dev libxtst-dev
# Clipboard
sudo apt install xsel xclip
# Bitmap
sudo apt install libpng++-dev
# GoHook
sudo apt install xcb libxcb-xkb-dev x11-xkb-utils libx11-xcb-dev libxkbcommon-x11-dev libxkbcommon-dev
```
##### Fedora:
```yml
# x11
sudo dnf install libXtst-devel
# Clipboard
sudo dnf install xsel xclip
# Bitmap
sudo dnf install libpng-devel
# GoHook
sudo dnf install libxkbcommon-devel libxkbcommon-x11-devel xorg-x11-xkb-utils-devel
```
## 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
```
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)
```Go
package main
import (
"fmt"
"github.com/go-vgo/robotgo"
)
func main() {
robotgo.MouseSleep = 300
robotgo.Move(100, 100)
fmt.Println(robotgo.Location())
robotgo.Move(100, -200) // multi screen supported
robotgo.MoveSmooth(120, -150)
fmt.Println(robotgo.Location())
robotgo.ScrollDir(10, "up")
robotgo.ScrollDir(20, "right")
robotgo.Scroll(0, -10)
robotgo.Scroll(100, 0)
robotgo.MilliSleep(100)
robotgo.ScrollSmooth(-10, 6)
// robotgo.ScrollRelative(10, -100)
robotgo.Move(10, 20)
robotgo.MoveRelative(0, -10)
robotgo.DragSmooth(10, 10)
robotgo.Click("wheelRight")
robotgo.Click("left", true)
robotgo.MoveSmooth(100, 200, 1.0, 10.0)
robotgo.Toggle("left")
robotgo.Toggle("left", "up")
}
```
#### [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.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)
}
}
```
#### [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
- Refactor some C code to Go (such as x11, windows)
- Better multiscreen support
- Wayland support
- Update Window Handle
- Try to support Android and 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 "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).
================================================
FILE: appveyor.yml
================================================
# version format
version: "{build}"
# Operating system (build VM template)
# os: Windows Server 2012 R2
os: Visual Studio 2017
# Platform.
# platform:
# - x64
# - x86
clone_folder: c:\gopath\src\github.com\go-vgo\robotgo
# Environment variables
environment:
global:
GOPATH: C:\gopath
CC: gcc.exe
matrix:
- GOARCH: amd64
# GOVERSION: 1.9.3
GETH_ARCH: amd64
MSYS2_ARCH: x86_64
MSYS2_BITS: 64
MSYSTEM: MINGW64
PATH: C:\msys64\mingw64\bin\;C:\Program Files (x86)\NSIS\;%PATH%
- GOARCH: 386
# GOVERSION: 1.9.3
GETH_ARCH: 386
MSYS2_ARCH: i686
MSYS2_BITS: 32
MSYSTEM: MINGW32
PATH: C:\msys64\mingw32\bin\;C:\Program Files (x86)\NSIS\;%PATH%
# - COMPILER: MINGW_W64
# ARCHITECTURE: x64
GOVERSION: 1.25.0
# GOPATH: c:\gopath
# scripts that run after cloning repository
# install:
# - set PATH=%GOPATH%\bin;c:\go\bin;%PATH%
# - go version
# - go env
# - gcc --version
# - python --version
install:
- set PATH=%GOPATH%\bin;c:\go\bin;%PATH%
- git submodule update --init
- rmdir C:\go /s /q
- appveyor DownloadFile https://storage.googleapis.com/golang/go%GOVERSION%.windows-%GETH_ARCH%.zip
- 7z x go%GOVERSION%.windows-%GETH_ARCH%.zip -y -oC:\ > NUL
- go version
- go env
- gcc --version
# To run your custom scripts instead of automatic MSBuild
build_script:
# We need to disable firewall - https://github.com/appveyor/ci/issues/1579#issuecomment-309830648
- ps: Disable-NetFirewallRule -DisplayName 'File and Printer Sharing (SMB-Out)'
- cd c:\gopath\src\github.com\go-vgo\robotgo
- git branch
- go get -t ./...
# To run your custom scripts instead of automatic tests
test_script:
# Unit tests
- ps: Add-AppveyorTest "Unit Tests" -Outcome Running
- go test -v github.com/go-vgo/robotgo/...
- ps: Update-AppveyorTest "Unit Tests" -Outcome Passed
# notifications:
# - provider: Email
# to:
# - .io
# on_build_failure: true
# on_build_status_changed: true
# to disable deployment
deploy: off
================================================
FILE: base/LICENSE
================================================
The software is licensed under the terms of the MIT license.
Copyright 2010 Michael Sanders, AE and the go-vgo Project Developers.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
================================================
FILE: base/MMBitmap.h
================================================
#pragma once
#ifndef MMBITMAP_H
#define MMBITMAP_H
#include "types.h"
#include "rgb.h"
#include <assert.h>
#include <stdint.h>
struct _MMBitmap {
uint8_t *imageBuffer; /* Pixels stored in Quad I format; */
int32_t width; /* Never 0, unless image is NULL. */
int32_t height; /* Never 0, unless image is NULL. */
int32_t bytewidth; /* The aligned width (width + padding). */
uint8_t bitsPerPixel; /* Should be either 24 or 32. */
uint8_t bytesPerPixel; /* For convenience; should be bitsPerPixel / 8. */
};
typedef struct _MMBitmap MMBitmap;
typedef MMBitmap *MMBitmapRef;
#define MMBitmapPointInBounds(image, p) ((p).x < (image)->width && (p).y < (image)->height)
/* Get pointer to pixel of MMBitmapRef. No bounds checking is performed */
#define MMRGBColorRefAtPoint(image, x, y) \
(MMRGBColor *)(assert(MMBitmapPointInBounds(image, MMPointInt32Make(x, y))), \
((image)->imageBuffer) + (((image)->bytewidth * (y)) + ((x) * (image)->bytesPerPixel)))
/* Dereference pixel of MMBitmapRef. Again, no bounds checking is performed. */
#define MMRGBColorAtPoint(image, x, y) *MMRGBColorRefAtPoint(image, x, y)
/* Hex/integer value of color at point. */
#define MMRGBHexAtPoint(image, x, y) hexFromMMRGB(MMRGBColorAtPoint(image, x, y))
#endif /* MMBITMAP_H */
================================================
FILE: base/base.go
================================================
// https://github.com/golang/go/issues/26366
package base
================================================
FILE: base/bitmap_free_c.h
================================================
#include "MMBitmap.h"
#include <assert.h>
#include <string.h>
MMBitmapRef createMMBitmap_c(uint8_t *buffer, int32_t width, int32_t height,
int32_t bytewidth, uint8_t bitsPerPixel, uint8_t bytesPerPixel
) {
MMBitmapRef bitmap = malloc(sizeof(MMBitmap));
if (bitmap == NULL) { return NULL; }
bitmap->imageBuffer = buffer;
bitmap->width = width;
bitmap->height = height;
bitmap->bytewidth = bytewidth;
bitmap->bitsPerPixel = bitsPerPixel;
bitmap->bytesPerPixel = bytesPerPixel;
return bitmap;
}
void destroyMMBitmap(MMBitmapRef bitmap) {
assert(bitmap != NULL);
if (bitmap->imageBuffer != NULL) {
free(bitmap->imageBuffer);
bitmap->imageBuffer = NULL;
}
free(bitmap);
}
void destroyMMBitmapBuffer(char * bitmapBuffer, void * hint) {
if (bitmapBuffer != NULL) {
free(bitmapBuffer);
}
}
================================================
FILE: base/deadbeef_rand.h
================================================
#ifndef DEADBEEF_RAND_H
#define DEADBEEF_RAND_H
#include <stdint.h>
#define DEADBEEF_MAX UINT32_MAX
/* Dead Beef Random Number Generator From: http://inglorion.net/software/deadbeef_rand */
/* Generates a random number between 0 and DEADBEEF_MAX. */
uint32_t deadbeef_rand(void);
/* Seeds with the given integer. */
void deadbeef_srand(uint32_t x);
/* Generates seed from the current time. */
uint32_t deadbeef_generate_seed(void);
/* Seeds with the above function. */
#define deadbeef_srand_time() deadbeef_srand(deadbeef_generate_seed())
/* Returns random double in the range [a, b).*/
#define DEADBEEF_UNIFORM(a, b) \
((a) + (deadbeef_rand() / (((double)DEADBEEF_MAX / (b - a) + 1))))
/* Returns random integer in the range [a, b).*/
#define DEADBEEF_RANDRANGE(a, b) (uint32_t)DEADBEEF_UNIFORM(a, b)
#endif /* DEADBEEF_RAND_H */
================================================
FILE: base/deadbeef_rand_c.h
================================================
#include "deadbeef_rand.h"
#include <time.h>
static uint32_t deadbeef_seed;
static uint32_t deadbeef_beef = 0xdeadbeef;
uint32_t deadbeef_rand(void) {
deadbeef_seed = (deadbeef_seed << 7) ^ ((deadbeef_seed >> 25) + deadbeef_beef);
deadbeef_beef = (deadbeef_beef << 7) ^ ((deadbeef_beef >> 25) + 0xdeadbeef);
return deadbeef_seed;
}
void deadbeef_srand(uint32_t x) {
deadbeef_seed = x;
deadbeef_beef = 0xdeadbeef;
}
/* Taken directly from the documentation: http://inglorion.net/software/cstuff/deadbeef_rand/ */
uint32_t deadbeef_generate_seed(void) {
uint32_t t = (uint32_t)time(NULL);
uint32_t c = (uint32_t)clock();
return (t << 24) ^ (c << 11) ^ t ^ (size_t) &c;
}
================================================
FILE: base/inline_keywords.h
================================================
#pragma once
/* A complicated, portable model for declaring inline functions in header files. */
#if !defined(H_INLINE)
#if defined(__GNUC__)
#define H_INLINE static __inline__ __attribute__((always_inline))
#elif defined(__MWERKS__) || defined(__cplusplus)
#define H_INLINE static inline
#elif defined(_MSC_VER)
#define H_INLINE static __inline
#elif TARGET_OS_WIN32
#define H_INLINE static __inline__
#endif
#endif /* H_INLINE */
================================================
FILE: base/microsleep.h
================================================
#pragma once
#ifndef MICROSLEEP_H
#define MICROSLEEP_H
#include "os.h"
#include "inline_keywords.h"
// todo: removed
#if !defined(IS_WINDOWS)
/* Make sure nanosleep gets defined even when using C89. */
#if !defined(__USE_POSIX199309) || !__USE_POSIX199309
#define __USE_POSIX199309 1
#endif
#include <time.h> /* For nanosleep() */
#endif
/* A more widely supported alternative to usleep(), based on Sleep() in Windows and nanosleep() */
H_INLINE void microsleep(double milliseconds) {
#if defined(IS_WINDOWS)
Sleep((DWORD)milliseconds); /* (Unfortunately truncated to a 32-bit integer.) */
#else
/* Technically, nanosleep() is not an ANSI function */
struct timespec sleepytime;
sleepytime.tv_sec = milliseconds / 1000;
sleepytime.tv_nsec = (milliseconds - (sleepytime.tv_sec * 1000)) * 1000000;
nanosleep(&sleepytime, NULL);
#endif
}
#endif /* MICROSLEEP_H */
================================================
FILE: base/os.h
================================================
#pragma once
#ifndef OS_H
#define OS_H
#if !defined(IS_MACOSX) && defined(__APPLE__) && defined(__MACH__)
#define IS_MACOSX
#endif /* IS_MACOSX */
#if !defined(IS_WINDOWS) && (defined(WIN32) || defined(_WIN32) || \
defined(__WIN32__) || defined(__WINDOWS__) || defined(__CYGWIN__))
#define IS_WINDOWS
#endif /* IS_WINDOWS */
#if !defined(USE_X11) && !defined(NUSE_X11) && !defined(IS_MACOSX) && !defined(IS_WINDOWS)
#define USE_X11
#endif /* USE_X11 */
#if defined(IS_WINDOWS)
#define STRICT /* Require use of exact types. */
#define WIN32_LEAN_AND_MEAN 1 /* Speed up compilation. */
#include <windows.h>
#elif !defined(IS_MACOSX) && !defined(USE_X11)
#error "Sorry, this platform isn't supported yet!"
#endif
/* Interval to align by for large buffers (e.g. bitmaps). Must be a power of 2. */
#ifndef BYTE_ALIGN
#define BYTE_ALIGN 4 /* Bytes to align pixel buffers to. */
/* #include <stddef.h> */
/* #define BYTE_ALIGN (sizeof(size_t)) */
#endif /* BYTE_ALIGN */
#if BYTE_ALIGN == 0
/* No alignment needed. */
#define ADD_PADDING(width) (width)
#else
/* Aligns given width to padding. */
#define ADD_PADDING(width) (BYTE_ALIGN + (((width) - 1) & ~(BYTE_ALIGN - 1)))
#endif
#if defined(IS_WINDOWS)
#if defined (_WIN64)
#define RobotGo_64
#else
#define RobotGo_32
#endif
#else
#if defined (__x86_64__)
#define RobotGo_64
#else
#define RobotGo_32
#endif
#endif
#endif /* OS_H */
================================================
FILE: base/pubs.h
================================================
#if defined(IS_WINDOWS)
BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
uint32_t *count = (uint32_t*)dwData;
(*count)++;
return TRUE;
}
typedef struct{
HWND hWnd;
DWORD dwPid;
}WNDINFO;
BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam){
WNDINFO* pInfo = (WNDINFO*)lParam;
DWORD dwProcessId = 0;
GetWindowThreadProcessId(hWnd, &dwProcessId);
if (dwProcessId == pInfo->dwPid) {
pInfo->hWnd = hWnd;
return FALSE;
}
return TRUE;
}
HWND GetHwndByPid(DWORD dwProcessId) {
WNDINFO info = {0};
info.hWnd = NULL;
info.dwPid = dwProcessId;
EnumWindows(EnumWindowsProc, (LPARAM)&info);
return info.hWnd;
}
#endif
================================================
FILE: base/rgb.h
================================================
#pragma once
#ifndef RGB_H
#define RGB_H
#include <stdlib.h> /* For abs() */
#include <math.h>
#include "inline_keywords.h" /* For H_INLINE */
#include <stdint.h>
/* #define MMRGB_IS_BGR (offsetof(MMRGBColor, red) > offsetof(MMRGBColor, blue)) */
#define MMRGB_IS_BGR 1
struct _MMRGBColor {
uint8_t blue;
uint8_t green;
uint8_t red;
};
typedef struct _MMRGBColor MMRGBColor;
/* MMRGBHex is a hexadecimal color value*/
typedef uint32_t MMRGBHex;
#define MMRGBHEX_MIN 0x000000
#define MMRGBHEX_MAX 0xFFFFFF
/* Converts rgb color to hexadecimal value. */
#define RGB_TO_HEX(red, green, blue) (((red) << 16) | ((green) << 8) | (blue))
/* Convenience wrapper for MMRGBColors. */
H_INLINE MMRGBHex hexFromMMRGB(MMRGBColor rgb) {
return RGB_TO_HEX(rgb.red, rgb.green, rgb.blue);
}
#define RED_FROM_HEX(hex) ((hex >> 16) & 0xFF)
#define GREEN_FROM_HEX(hex) ((hex >> 8) & 0xFF)
#define BLUE_FROM_HEX(hex) (hex & 0xFF)
/* Converts hexadecimal color to MMRGBColor. */
H_INLINE MMRGBColor MMRGBFromHex(MMRGBHex hex) {
MMRGBColor color;
color.red = RED_FROM_HEX(hex);
color.green = GREEN_FROM_HEX(hex);
color.blue = BLUE_FROM_HEX(hex);
return color;
}
/* Check absolute equality of two RGB colors. */
#define MMRGBColorEqualToColor(c1, c2) ((c1).red == (c2).red && \
(c1).blue == (c2).blue && \
(c1).green == (c2).green)
/* Returns whether two colors are similar within the given range, |tolerance|.*/
H_INLINE int MMRGBColorSimilarToColor(MMRGBColor c1, MMRGBColor c2, float tolerance) {
/* Speedy case */
if (tolerance <= 0.0f) {
return MMRGBColorEqualToColor(c1, c2);
} else { /* Otherwise, use a Euclidean space to determine similarity */
uint8_t d1 = c1.red - c2.red;
uint8_t d2 = c1.green - c2.green;
uint8_t d3 = c1.blue - c2.blue;
return sqrt((double)(d1 * d1) + (d2 * d2) +
(d3 * d3)) <= (tolerance * 442.0f);
}
}
/* Identical to MMRGBColorSimilarToColor, only for hex values. */
H_INLINE int MMRGBHexSimilarToColor(MMRGBHex h1, MMRGBHex h2, float tolerance) {
if (tolerance <= 0.0f) {
return h1 == h2;
} else {
int d1 = RED_FROM_HEX(h1) - RED_FROM_HEX(h2);
int d2 = GREEN_FROM_HEX(h1) - GREEN_FROM_HEX(h2);
int d3 = BLUE_FROM_HEX(h1) - BLUE_FROM_HEX(h2);
return sqrt((double)(d1 * d1) + (d2 * d2) +
(d3 * d3)) <= (tolerance * 442.0f);
}
}
#endif /* RGB_H */
================================================
FILE: base/types.h
================================================
#pragma once
#ifndef TYPES_H
#define TYPES_H
#include "os.h"
#include "inline_keywords.h" /* For H_INLINE */
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
/* Some generic, cross-platform types. */
#ifdef RobotGo_64
typedef int64_t intptr;
typedef uint64_t uintptr;
#else
typedef int32_t intptr;
typedef uint32_t uintptr; // Unsigned pointer integer
#endif
struct _MMPointInt32 {
int32_t x;
int32_t y;
};
typedef struct _MMPointInt32 MMPointInt32;
struct _MMSizeInt32 {
int32_t w;
int32_t h;
};
typedef struct _MMSizeInt32 MMSizeInt32;
struct _MMRectInt32 {
MMPointInt32 origin;
MMSizeInt32 size;
};
typedef struct _MMRectInt32 MMRectInt32;
H_INLINE MMPointInt32 MMPointInt32Make(int32_t x, int32_t y) {
MMPointInt32 point;
point.x = x;
point.y = y;
return point;
}
H_INLINE MMSizeInt32 MMSizeInt32Make(int32_t w, int32_t h) {
MMSizeInt32 size;
size.w = w;
size.h = h;
return size;
}
H_INLINE MMRectInt32 MMRectInt32Make(int32_t x, int32_t y, int32_t w, int32_t h) {
MMRectInt32 rect;
rect.origin = MMPointInt32Make(x, y);
rect.size = MMSizeInt32Make(w, h);
return rect;
}
#define MMPointZero MMPointInt32Make(0, 0)
#if defined(IS_MACOSX)
#define CGPointFromMMPointInt32(p) CGPointMake((CGFloat)(p).x, (CGFloat)(p).y)
#define MMPointInt32FromCGPoint(p) MMPointInt32Make((int32_t)(p).x, (int32_t)(p).y)
#elif defined(IS_WINDOWS)
#define MMPointInt32FromPOINT(p) MMPointInt32Make((int32_t)p.x, (int32_t)p.y)
#endif
#endif /* TYPES_H */
================================================
FILE: base/xdisplay_c.h
================================================
#include <stdio.h> /* For fputs() */
#include <stdlib.h> /* For atexit() */
#include <X11/Xlib.h>
static Display *mainDisplay = NULL;
static int registered = 0;
static char *displayName = NULL;
static int hasDisplayNameChanged = 0;
void XCloseMainDisplay(void) {
if (mainDisplay != NULL) {
XCloseDisplay(mainDisplay);
mainDisplay = NULL;
}
}
Display *XGetMainDisplay(void) {
/* Close the display if displayName has changed */
if (hasDisplayNameChanged) {
XCloseMainDisplay();
hasDisplayNameChanged = 0;
}
if (mainDisplay == NULL) {
/* First try the user set displayName */
mainDisplay = XOpenDisplay(displayName);
/* Then try using environment variable DISPLAY */
if (mainDisplay == NULL && displayName != NULL) {
mainDisplay = XOpenDisplay(NULL);
}
/* Fall back to the most likely :0.0*/
if (mainDisplay == NULL) {
mainDisplay = XOpenDisplay(":0.0");
}
if (mainDisplay == NULL) {
fputs("Could not open main display\n", stderr);
} else if (!registered) {
atexit(&XCloseMainDisplay);
registered = 1;
}
}
return mainDisplay;
}
void setXDisplay(char *name) {
displayName = strdup(name);
hasDisplayNameChanged = 1;
}
char *getXDisplay(void) {
return displayName;
}
================================================
FILE: 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)
<!--[](https://drone.io/github.com/atotto/clipboard/latest) -->
# Clipboard for Go
Provide copying and pasting to the Clipboard for Go.
<!--Download shell commands at https://drone.io/github.com/atotto/clipboard/files-->
Build:
$ go get github.com/atotto/clipboard
Platforms:
* OSX
* Windows 7 (probably work on other Windows)
* Linux, Unix (requires 'xclip' or 'xsel' command to be installed)
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
================================================
FILE: clipboard/clipboard.go
================================================
// Copyright 2013 @atotto. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
/*
Package clipboard read/write on clipboard
*/
package clipboard
// import ()
// ReadAll read string from clipboard
func ReadAll() (string, error) {
return readAll()
}
// WriteAll write string to clipboard
func WriteAll(text string) error {
return writeAll(text)
}
// Unsupported might be set true during clipboard init,
// to help callers decide whether or not to
// offer clipboard options.
var Unsupported bool
================================================
FILE: clipboard/clipboard_darwin.go
================================================
// Copyright 2013 @atotto. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build darwin
// +build darwin
package clipboard
import (
"os/exec"
)
var (
pasteCmdArgs = "pbpaste"
copyCmdArgs = "pbcopy"
)
func getPasteCommand() *exec.Cmd {
return exec.Command(pasteCmdArgs)
}
func getCopyCommand() *exec.Cmd {
return exec.Command(copyCmdArgs)
}
func readAll() (string, error) {
pasteCmd := getPasteCommand()
out, err := pasteCmd.Output()
if err != nil {
return "", err
}
return string(out), nil
}
func writeAll(text string) error {
copyCmd := getCopyCommand()
in, err := copyCmd.StdinPipe()
if err != nil {
return err
}
if err := copyCmd.Start(); err != nil {
return err
}
if _, err := in.Write([]byte(text)); err != nil {
return err
}
if err := in.Close(); err != nil {
return err
}
return copyCmd.Wait()
}
================================================
FILE: clipboard/clipboard_test.go
================================================
// Copyright 2013 @atotto. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build darwin || windows
// +build darwin windows
package clipboard_test
import (
"testing"
"github.com/go-vgo/robotgo/clipboard"
)
func TestCopyAndPaste(t *testing.T) {
expected := "日本語"
err := clipboard.WriteAll(expected)
if err != nil {
t.Fatal(err)
}
actual, err := clipboard.ReadAll()
if err != nil {
t.Fatal(err)
}
if actual != expected {
t.Errorf("want %s, got %s", expected, actual)
}
}
func TestMultiCopyAndPaste(t *testing.T) {
expected1 := "French: éèêëàùœç"
expected2 := "Weird UTF-8: 💩☃"
err := clipboard.WriteAll(expected1)
if err != nil {
t.Fatal(err)
}
actual1, err := clipboard.ReadAll()
if err != nil {
t.Fatal(err)
}
if actual1 != expected1 {
t.Errorf("want %s, got %s", expected1, actual1)
}
err = clipboard.WriteAll(expected2)
if err != nil {
t.Fatal(err)
}
actual2, err := clipboard.ReadAll()
if err != nil {
t.Fatal(err)
}
if actual2 != expected2 {
t.Errorf("want %s, got %s", expected2, actual2)
}
}
func BenchmarkReadAll(b *testing.B) {
for i := 0; i < b.N; i++ {
clipboard.ReadAll()
}
}
func BenchmarkWriteAll(b *testing.B) {
text := "いろはにほへと"
for i := 0; i < b.N; i++ {
clipboard.WriteAll(text)
}
}
================================================
FILE: clipboard/clipboard_unix.go
================================================
// Copyright 2013 @atotto. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build freebsd || linux || netbsd || openbsd || solaris || dragonfly
// +build freebsd linux netbsd openbsd solaris dragonfly
package clipboard
import (
"errors"
"os/exec"
)
const (
xsel = "xsel"
xclip = "xclip"
)
var (
// Primary choose primary mode on unix
Primary bool
pasteCmdArgs, copyCmdArgs []string
xselPasteArgs = []string{xsel, "--output", "--clipboard"}
xselCopyArgs = []string{xsel, "--input", "--clipboard"}
xclipPasteArgs = []string{xclip, "-out", "-selection", "clipboard"}
xclipCopyArgs = []string{xclip, "-in", "-selection", "clipboard"}
errMissingCommands = errors.New("No clipboard utilities available. Please install xsel or xclip")
)
func init() {
pasteCmdArgs = xclipPasteArgs
copyCmdArgs = xclipCopyArgs
if _, err := exec.LookPath(xclip); err == nil {
return
}
pasteCmdArgs = xselPasteArgs
copyCmdArgs = xselCopyArgs
if _, err := exec.LookPath(xsel); err == nil {
return
}
Unsupported = true
}
func getPasteCommand() *exec.Cmd {
if Primary {
pasteCmdArgs = pasteCmdArgs[:1]
}
return exec.Command(pasteCmdArgs[0], pasteCmdArgs[1:]...)
}
func getCopyCommand() *exec.Cmd {
if Primary {
copyCmdArgs = copyCmdArgs[:1]
}
return exec.Command(copyCmdArgs[0], copyCmdArgs[1:]...)
}
func readAll() (string, error) {
if Unsupported {
return "", errMissingCommands
}
pasteCmd := getPasteCommand()
out, err := pasteCmd.Output()
if err != nil {
return "", err
}
return string(out), nil
}
func writeAll(text string) error {
if Unsupported {
return errMissingCommands
}
copyCmd := getCopyCommand()
in, err := copyCmd.StdinPipe()
if err != nil {
return err
}
if err := copyCmd.Start(); err != nil {
return err
}
if _, err := in.Write([]byte(text)); err != nil {
return err
}
if err := in.Close(); err != nil {
return err
}
return copyCmd.Wait()
}
================================================
FILE: clipboard/clipboard_windows.go
================================================
// Copyright 2013 @atotto. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build windows
// +build windows
package clipboard
import (
"syscall"
"time"
"unsafe"
)
const (
cfUnicodetext = 13
// gmemFixed = 0x0000
gmemMoveable = 0x0002
)
var (
user32 = syscall.MustLoadDLL("user32")
openClipboard = user32.MustFindProc("OpenClipboard")
closeClipboard = user32.MustFindProc("CloseClipboard")
emptyClipboard = user32.MustFindProc("EmptyClipboard")
getClipboardData = user32.MustFindProc("GetClipboardData")
setClipboardData = user32.MustFindProc("SetClipboardData")
kernel32 = syscall.NewLazyDLL("kernel32")
globalAlloc = kernel32.NewProc("GlobalAlloc")
globalFree = kernel32.NewProc("GlobalFree")
globalLock = kernel32.NewProc("GlobalLock")
globalUnlock = kernel32.NewProc("GlobalUnlock")
lstrcpy = kernel32.NewProc("lstrcpyW")
)
// waitOpenClipboard opens the clipboard, waiting for up to a second to do so.
func waitOpenClipboard() error {
started := time.Now()
limit := started.Add(time.Second)
var (
r uintptr
err error
)
for time.Now().Before(limit) {
r, _, err = openClipboard.Call(0)
if r != 0 {
return nil
}
time.Sleep(time.Millisecond)
}
return err
}
func readAll() (string, error) {
// r, _, err := openClipboard.Call(0)
err := waitOpenClipboard()
if err != nil {
return "", err
}
defer closeClipboard.Call()
h, _, err := getClipboardData.Call(cfUnicodetext)
if h == 0 {
return "", err
}
l, _, err := globalLock.Call(h)
if l == 0 {
return "", err
}
text := syscall.UTF16ToString((*[1 << 20]uint16)(unsafe.Pointer(l))[:])
r, _, err := globalUnlock.Call(h)
if r == 0 {
return "", err
}
return text, nil
}
func writeAll(text string) error {
err := waitOpenClipboard()
if err != nil {
return err
}
defer closeClipboard.Call()
r, _, err := emptyClipboard.Call(0)
if r == 0 {
return err
}
data := syscall.StringToUTF16(text)
// "If the hMem parameter identifies a memory object, the object must have
// been allocated using the function with the GMEM_MOVEABLE flag."
h, _, err := globalAlloc.Call(gmemMoveable,
uintptr(len(data)*int(unsafe.Sizeof(data[0]))))
if h == 0 {
return err
}
defer func() {
if h != 0 {
globalFree.Call(h)
}
}()
l, _, err := globalLock.Call(h)
if l == 0 {
return err
}
r, _, err = lstrcpy.Call(l, uintptr(unsafe.Pointer(&data[0])))
if r == 0 {
return err
}
r, _, err = globalUnlock.Call(h)
if r == 0 {
if err.(syscall.Errno) != 0 {
return err
}
}
r, _, err = setClipboardData.Call(cfUnicodetext, h)
if r == 0 {
return err
}
h = 0 // suppress deferred cleanup
return nil
}
================================================
FILE: clipboard/cmd/gocopy/gocopy.go
================================================
package main
import (
"io"
"os"
"github.com/go-vgo/robotgo/clipboard"
)
func main() {
out, err := io.ReadAll(os.Stdin)
if err != nil {
panic(err)
}
if err := clipboard.WriteAll(string(out)); err != nil {
panic(err)
}
}
================================================
FILE: clipboard/cmd/gopaste/gopaste.go
================================================
package main
import (
"fmt"
"github.com/go-vgo/robotgo/clipboard"
)
func main() {
text, err := clipboard.ReadAll()
if err != nil {
panic(err)
}
fmt.Print(text)
}
================================================
FILE: clipboard/example/example.go
================================================
package main
import (
"log"
"github.com/go-vgo/robotgo/clipboard"
)
func main() {
err := clipboard.WriteAll("日本語")
if err != nil {
log.Println("clipboard write all error: ", err)
}
text, err := clipboard.ReadAll()
if err != nil {
log.Println("clipboard read all error: ", err)
return
}
if text != "" {
log.Println("text is: ", text)
// Output: 日本語
}
}
================================================
FILE: cv/README.md
================================================
robotgo gocv
================================================
FILE: cv/gocv.go
================================================
package cv
================================================
FILE: doc.go
================================================
// Copyright (c) 2016-2025 AtomAI, All rights reserved.
//
// See the COPYRIGHT file at the top-level directory of this distribution and at
// https://github.com/go-vgo/robotgo/blob/master/LICENSE
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0>
//
// This file may not be copied, modified, or distributed
// except according to those terms.
package robotgo
/*
Keys are supported:
"A-Z a-z 0-9"
"backspace"
"delete"
"enter"
"tab"
"esc"
"escape"
"up" Up arrow key
"down" Down arrow key
"right" Right arrow key
"left" Left arrow key
"home"
"end"
"pageup"
"pagedown"
"f1"
"f2"
"f3"
"f4"
"f5"
"f6"
"f7"
"f8"
"f9"
"f10"
"f11"
"f12"
"f13"
"f14"
"f15"
"f16"
"f17"
"f18"
"f19"
"f20"
"f21"
"f22"
"f23"
"f24"
"cmd" this is the "win" key for windows
"lcmd" left command
"rcmd" right command
// "command"
"alt"
"lalt" left alt
"ralt" right alt
"ctrl"
"lctrl" left ctrl
"rctrl" right ctrl
"control"
"shift"
"lshift" left shift
"rshift" right shift
// "right_shift"
"capslock"
"space"
"print"
"printscreen" // No Mac support
"insert"
"menu" Windows only
"audio_mute" Mute the volume
"audio_vol_down" Lower the volume
"audio_vol_up" Increase the volume
"audio_play"
"audio_stop"
"audio_pause"
"audio_prev" Previous Track
"audio_next" Next Track
"audio_rewind" Linux only
"audio_forward" Linux only
"audio_repeat" Linux only
"audio_random" Linux only
"num0"
"num1"
"num2"
"num3"
"num4"
"num5"
"num6"
"num7"
"num8"
"num9"
"num_lock"
"num."
"num+"
"num-"
"num*"
"num/"
"num_clear"
"num_enter"
"num_equal"
"lights_mon_up" Turn up monitor brightness No Windows support
"lights_mon_down" Turn down monitor brightness No Windows support
"lights_kbd_toggle" Toggle keyboard backlight on/off No Windows support
"lights_kbd_up" Turn up keyboard backlight brightness No Windows support
"lights_kbd_down" Turn down keyboard backlight brightness No Windows support
*/
/*
## 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()
*/
================================================
FILE: docs/CHANGELOG.md
================================================
# CHANGELOG
<!--### RobotGo-->
## 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
================================================
FILE: docs/README.md
================================================
# Docs
Documents are not necessarily updated synchronously, slower than godoc, please see examples and godoc.
================================================
FILE: 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>
<!-- - [中文文档](https://github.com/go-vgo/robotgo/blob/master/docs/doc_zh.md) (弃用)
- [English Docs](https://github.com/go-vgo/robotgo/blob/master/docs/doc.md) (弃用) -->
## 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).
================================================
FILE: docs/archive/doc.md
================================================
# Methods:
##### [GetVersion](#GetVersion)
## [Keyboard](#Keyboard)
##### [Keys](https://github.com/go-vgo/robotgo/blob/master/docs/keys.md)
<!-- ##### [SetKeyboardDelay](#SetKeyDelay) (Equivalent to SetKeyDelay, Wno-deprecated) -->
##### [SetKeyDelay](#SetKeyDelay)
##### [KeyTap](#KeyTap)
##### [KeyToggle](#KeyToggle)
<!-- ##### [TypeString](#TypeString)
##### [TypeStringDelayed](#TypeStrDelay) (Equivalent to TypeStrDelay, Wno-deprecated) -->
##### [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)
<!-- ##### [LEvent](#LEvent) (Equivalent to AddEvent, Wno-deprecated) -->
##### [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)
<!-- ##### [GetBHandle](#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="TypeString">.TypeString(string)</h3>
#### Arguments:
string - The string to send. -->
### <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
<!-- Capture_Screen (Drop support) -->
#### 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
================================================
FILE: docs/archive/doc_zh.md
================================================
# 方法:
##### [GetVersion](#GetVersion)
## [键盘](#Keyboard)
##### [Keys](https://github.com/go-vgo/robotgo/blob/master/docs/keys.md)
<!-- ##### [SetKeyboardDelay](#SetKeyDelay) (相当于 SetKeyDelay, 废弃 API) -->
##### [SetKeyDelay](#SetKeyDelay)
##### [KeyTap](#KeyTap)
##### [KeyToggle](#KeyToggle)
<!-- ##### [TypeString](#TypeString)
##### [TypeStringDelayed](#TypeStrDelay) (相当于 TypeStrDelay, 废弃 API) -->
##### [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)
<!-- ##### [LEvent](#AddEvent) (相当于 AddEvent, 废弃 API) -->
##### [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)
<!-- ##### [GetBHandle](#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="TypeString">.TypeString(string)</h3>
#### 参数:
string - The string to send. -->
### <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
<!-- Capture_Screen (废弃) -->
#### 参数:
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
================================================
FILE: docs/install.md
================================================
## 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).
================================================
FILE: 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
```Go
"A-Z a-z 0-9"
"backspace"
"delete"
"enter"
"tab"
"esc"
"escape"
"up" Up arrow key
"down" Down arrow key
"right" Right arrow key
"left" Left arrow key
"home"
"end"
"pageup"
"pagedown"
"f1"
"f2"
"f3"
"f4"
"f5"
"f6"
"f7"
"f8"
"f9"
"f10"
"f11"
"f12"
"f13"
"f14"
"f15"
"f16"
"f17"
"f18"
"f19"
"f20"
"f21"
"f22"
"f23"
"f24"
"cmd" is the "win" key for windows
"lcmd" left command
"rcmd" right command
// "command"
"alt"
"lalt" left alt
"ralt" right alt
"ctrl"
"lctrl" left ctrl
"rctrl" right ctrl
"control"
"shift"
"lshift" left shift
"rshift" right shift
// "right_shift"
"capslock"
"space"
"print"
"printscreen" // No Mac support
"insert"
"menu" Windows only
"audio_mute" Mute the volume
"audio_vol_down" Lower the volume
"audio_vol_up" Increase the volume
"audio_play"
"audio_stop"
"audio_pause"
"audio_prev" Previous Track
"audio_next" Next Track
"audio_rewind" Linux only
"audio_forward" Linux only
"audio_repeat" Linux only
"audio_random" Linux only
"num0"
"num1"
"num2"
"num3"
"num4"
"num5"
"num6"
"num7"
"num8"
"num9"
"num_lock"
"num."
"num+"
"num-"
"num*"
"num/"
"num_clear"
"num_enter"
"num_equal"
// // "numpad_0" No Linux support
// "numpad_0"
// "numpad_1"
// "numpad_2"
// "numpad_3"
// "numpad_4"
// "numpad_5"
// "numpad_6"
// "numpad_7"
// "numpad_8"
// "numpad_9"
// "numpad_lock"
"lights_mon_up" Turn up monitor brightness No Windows support
"lights_mon_down" Turn down monitor brightness No Windows support
"lights_kbd_toggle" Toggle keyboard backlight on/off No Windows support
"lights_kbd_up" Turn up keyboard backlight brightness No Windows support
"lights_kbd_down" Turn down keyboard backlight brightness No Windows support
```
================================================
FILE: event/android/event_c.h
================================================
#include <linux/input.h>
#include <string.h>
================================================
FILE: event/ios/event_c.h
================================================
#include <AppKit/NSEvent.h>
#include <string.h>
================================================
FILE: 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)
}
```
================================================
FILE: examples/key/main.go
================================================
// Copyright (c) 2016-2025 AtomAI, All rights reserved.
//
// See the COPYRIGHT file at the top-level directory of this distribution and at
// https://github.com/go-vgo/robotgo/blob/master/LICENSE
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0>
//
// This file may not be copied, modified, or distributed
// except according to those terms.
package main
import (
"fmt"
"github.com/go-vgo/robotgo"
// "go-vgo/robotgo"
)
func typeStr() {
// typing "Hello World"
robotgo.Type("Hello World!", 0, 1)
robotgo.KeySleep = 100
robotgo.Type("だんしゃり")
robotgo.Type("Hi galaxy, hi stars, hi MT.Rainier, hi sea. こんにちは世界.")
robotgo.Type("So, hi, bye! 你好, 再见!")
robotgo.Sleep(1)
robotgo.Type("Hi, Seattle space needle, Golden gate bridge, One world trade center.")
robotgo.MilliSleep(100)
ustr := uint32(robotgo.CharCodeAt("So, hi, bye!", 0))
robotgo.UnicodeType(ustr)
err := robotgo.Paste("paste string")
fmt.Println("PasteStr: ", err)
}
func keyTap() {
// press "enter"
robotgo.KeyTap("enter")
robotgo.KeyTap(robotgo.Enter)
robotgo.KeySleep = 200
robotgo.KeyTap("a")
robotgo.MilliSleep(100)
robotgo.KeyTap("a", "ctrl")
// hide window
err := robotgo.KeyTap("h", "cmd")
if err != nil {
fmt.Println("robotgo.KeyTap run error is: ", err)
}
robotgo.KeyTap("h", "cmd")
// press "i", "alt", "command" Key combination
robotgo.KeyTap(robotgo.KeyI, robotgo.Alt, robotgo.Cmd)
robotgo.KeyTap("i", "alt", "cmd")
arr := []string{"alt", "cmd"}
robotgo.KeyTap("i", arr)
robotgo.KeyTap("i", arr)
robotgo.KeyTap("i", "cmd", " alt", "shift")
// close window
robotgo.KeyTap("w", "cmd")
// minimize window
robotgo.KeyTap("m", "cmd")
robotgo.KeyTap("f1", "ctrl")
robotgo.KeyTap("a", "control")
}
func special() {
robotgo.Type("{}")
robotgo.KeyTap("[", "]")
robotgo.KeyToggle("(")
robotgo.KeyToggle("(", "up")
}
func keyToggle() {
// robotgo.KeySleep = 150
robotgo.KeyToggle(robotgo.KeyA)
robotgo.KeyToggle("a", "down", "alt")
robotgo.Sleep(1)
robotgo.KeyToggle("a", "up", "alt", "cmd")
robotgo.MilliSleep(100)
robotgo.KeyToggle("q", "up", "alt", "cmd", "shift")
err := robotgo.KeyToggle(robotgo.Enter)
if err != nil {
fmt.Println("robotgo.KeyToggle run error is: ", err)
}
}
func cilp() {
// robotgo.TypeStr("en")
// write string to clipboard
e := robotgo.WriteAll("テストする")
if e != nil {
fmt.Println("robotgo.WriteAll err is: ", e)
}
// read string from clipboard
text, err := robotgo.ReadAll()
if err != nil {
fmt.Println("robotgo.ReadAll err is: ", err)
}
fmt.Println("text: ", text)
}
func key() {
////////////////////////////////////////////////////////////////////////////////
// Control the keyboard
////////////////////////////////////////////////////////////////////////////////
typeStr()
special()
keyTap()
keyToggle()
cilp()
}
func main() {
key()
}
================================================
FILE: examples/main.go
================================================
// Copyright (c) 2016-2025 AtomAI go-vgo, All rights reserved.
//
// See the COPYRIGHT file at the top-level directory of this distribution and at
// https://github.com/go-vgo/robotgo/blob/master/LICENSE
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0>
//
// This file may not be copied, modified, or distributed
// except according to those terms.
package main
import (
"fmt"
"github.com/go-vgo/robotgo"
// "go-vgo/robotgo"
)
func main() {
ver := robotgo.GetVersion()
fmt.Println("robotgo version is: ", ver)
// Control the keyboard
// key()
// Control the mouse
// mouse()
// Read the screen
// screen()
// Bitmap and image processing
// bitmap()
// Global event listener
// event()
// Window Handle and progress
// window()
}
================================================
FILE: examples/mouse/main.go
================================================
// Copyright (c) 2016-2025 AtomAI, All rights reserved.
//
// See the COPYRIGHT file at the top-level directory of this distribution and at
// https://github.com/go-vgo/robotgo/blob/master/LICENSE
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0>
//
// This file may not be copied, modified, or distributed
// except according to those terms.
package main
import (
"fmt"
"github.com/go-vgo/robotgo"
// "go-vgo/robotgo"
)
func move() {
robotgo.MouseSleep = 100
robotgo.Move(100, 200)
robotgo.MoveRelative(10, -200)
// move the mouse to 100, 200
robotgo.Move(100, 200)
// drag mouse with smooth
robotgo.DragSmooth(10, 10)
robotgo.DragSmooth(100, 200, 1.0, 100.0)
// smooth move the mouse to 100, 200
robotgo.MoveSmooth(100, 200)
robotgo.MoveSmooth(100, 200, 1.0, 100.0)
robotgo.MoveSmoothRelative(10, -100, 1.0, 30.0)
for i := 0; i < 1080; i += 1000 {
fmt.Println("i: ", i)
// MoveMouse(800, i)
robotgo.Move(800, i)
}
}
func click() {
// click the left mouse button
robotgo.Click()
// click the right mouse button
robotgo.Click("right", false)
// double click the left mouse button
robotgo.Click("left", true)
}
func get() {
// gets the mouse coordinates
x, y := robotgo.Location()
fmt.Println("pos:", x, y)
if x == 456 && y == 586 {
fmt.Println("mouse...", "586")
}
robotgo.Move(x, y)
}
func toggleAndScroll() {
// scrolls the mouse either up
robotgo.ScrollDir(10, "up")
robotgo.ScrollDir(10, "right")
robotgo.Scroll(100, 10)
robotgo.Scroll(0, -10)
robotgo.Toggle("left")
robotgo.Toggle("left", "up")
// toggles the right mouse button
robotgo.Toggle("right")
robotgo.Toggle("right", "up")
}
func mouse() {
////////////////////////////////////////////////////////////////////////////////
// Control the mouse
////////////////////////////////////////////////////////////////////////////////
move()
click()
get()
toggleAndScroll()
}
func main() {
mouse()
}
================================================
FILE: examples/scale/main.go
================================================
package main
import (
"fmt"
"github.com/go-vgo/robotgo"
)
func main() {
// syscall.NewLazyDLL("user32.dll").NewProc("SetProcessDPIAware").Call()
width, height := robotgo.GetScaleSize()
fmt.Println("get scale screen size: ", width, height)
bitmap := robotgo.CaptureScreen(0, 0, width, height)
defer robotgo.FreeBitmap(bitmap)
// bitmap.Save(bitmap, "test.png")
robotgo.Save(robotgo.ToImage(bitmap), "test.png")
robotgo.Scale = true
robotgo.Move(10, 10)
robotgo.MoveSmooth(100, 100)
fmt.Println(robotgo.Location())
num := robotgo.DisplaysNum()
for i := 0; i < num; i++ {
rect := robotgo.GetScreenRect(i)
fmt.Println("rect: ", rect)
}
}
func old() {
sx := robotgo.ScaleX() // Deprecated
s := robotgo.Scale1() // Deprecated, use the ScaleF() function
robotx, roboty := 35*s/100, 25*s/100
fmt.Println("scale: ", sx, s, " pos: ", robotx, roboty)
mx, my := robotgo.Location()
sx, sy := mx*s/100, my*s/100
rx, ry, rw, rh := sx, sy, robotx, roboty
// bit1 := robotgo.CaptureScreen(10, 20, robotw, roboth)
bit1 := robotgo.CaptureScreen(rx, ry, rw, rh)
defer robotgo.FreeBitmap(bit1)
// bitmap.Save(bit1, "test2.png")
robotgo.Save(robotgo.ToImage(bit1), "test2.png")
clo := robotgo.GetPixelColor(robotx, roboty)
fmt.Println("GetPixelColor...", clo)
}
================================================
FILE: examples/screen/main.go
================================================
// Copyright (c) 2016-2025 AtomAI, All rights reserved.
//
// See the COPYRIGHT file at the top-level directory of this distribution and at
// https://github.com/go-vgo/robotgo/blob/master/LICENSE
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0>
//
// This file may not be copied, modified, or distributed
// except according to those terms.
package main
import (
"fmt"
"strconv"
"github.com/go-vgo/robotgo"
// "go-vgo/robotgo"
)
func bitmap() {
bit := robotgo.CaptureScreen()
defer robotgo.FreeBitmap(bit)
fmt.Println("abitMap...", bit)
gbit := robotgo.ToBitmap(bit)
fmt.Println("bitmap...", gbit.Width)
gbitMap := robotgo.CaptureGo()
fmt.Println("Go CaptureScreen...", gbitMap.Width)
// fmt.Println("...", gbitmap.Width, gbitmap.BytesPerPixel)
robotgo.SaveCapture("saveCapture.png", 10, 20, 100, 100)
img, err := robotgo.CaptureImg()
fmt.Println("error: ", err)
robotgo.Save(img, "save.png")
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)
path2 := "test_" + strconv.Itoa(i)
robotgo.Save(img2, path2+".png")
robotgo.SaveJpeg(img2, path2+".jpeg", 50)
x, y, w, h := robotgo.GetDisplayBounds(i)
img3, err := robotgo.CaptureImg(x, y, w, h)
fmt.Println("Capture error: ", err)
robotgo.Save(img3, path2+"_1.png")
}
}
func color() {
// gets the pixel color at 100, 200.
color := robotgo.GetPixelColor(100, 200)
fmt.Println("color----", color, "-----------------")
clo := robotgo.GetPxColor(100, 200)
fmt.Println("color...", clo)
clostr := robotgo.PadHex(clo)
fmt.Println("color...", clostr)
rgb := robotgo.RgbToHex(255, 100, 200)
rgbstr := robotgo.PadHex(robotgo.U32ToHex(rgb))
fmt.Println("rgb...", rgbstr)
hex := robotgo.HexToRgb(uint32(rgb))
fmt.Println("hex...", hex)
hexh := robotgo.PadHex(robotgo.U8ToHex(hex))
fmt.Println("HexToRgb...", hexh)
// gets the pixel color at 10, 20.
color2 := robotgo.GetPixelColor(10, 20)
fmt.Println("color---", color2)
}
func screen() {
////////////////////////////////////////////////////////////////////////////////
// Read the screen
////////////////////////////////////////////////////////////////////////////////
bitmap()
// gets the screen width and height
sx, sy := robotgo.GetScreenSize()
fmt.Println("get screen size: ", sx, sy)
for i := 0; i < robotgo.DisplaysNum(); i++ {
s1 := robotgo.ScaleF(i)
fmt.Println("ScaleF: ", s1)
}
sx, sy = robotgo.GetScaleSize()
fmt.Println("get screen scale size: ", sx, sy)
color()
}
func main() {
screen()
}
================================================
FILE: examples/window/main.go
================================================
// Copyright (c) 2016-2025 AtomAI, All rights reserved.
//
// See the COPYRIGHT file at the top-level directory of this distribution and at
// https://github.com/go-vgo/robotgo/blob/master/LICENSE
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0>
//
// This file may not be copied, modified, or distributed
// except according to those terms.
package main
import (
"fmt"
"github.com/go-vgo/robotgo"
// "go-vgo/robotgo"
)
func alert() {
// show Alert Window
abool := robotgo.Alert("hello", "robotgo")
if abool {
fmt.Println("ok@@@", "ok")
}
robotgo.Alert("hello", "robotgo", "Ok", "Cancel")
}
func get() {
// get the current process id
pid := robotgo.GetPid()
fmt.Println("pid----", pid)
// get current Window Active
mdata := robotgo.GetActive()
// get current Window Handle
hwnd := robotgo.GetHandle()
fmt.Println("hwnd---", hwnd)
// get current Window title
title := robotgo.GetTitle()
fmt.Println("title-----", title)
// set Window Active
robotgo.SetActive(mdata)
}
func findIds() {
// find the process id by the process name
fpid, err := robotgo.FindIds("Google")
if err != nil {
fmt.Println(err)
return
}
if len(fpid) > 0 {
robotgo.KeyTap("a", fpid[0])
robotgo.TypeStr("Hi galaxy!", fpid[0])
robotgo.KeyToggle("a", fpid[0], "cmd")
robotgo.KeyToggle("a", fpid[0], "cmd", "up")
}
fmt.Println("pids...", fpid)
if len(fpid) > 0 {
err = robotgo.ActivePid(fpid[0])
if err != nil {
fmt.Println(err)
}
tl := robotgo.GetTitle(fpid[0])
fmt.Println("pid[0] title is: ", tl)
x, y, w, h := robotgo.GetBounds(fpid[0])
fmt.Println("GetBounds is: ", x, y, w, h)
// Windows
// hwnd := robotgo.FindWindow("google")
// hwnd := robotgo.GetHWND()
robotgo.MinWindow(fpid[0])
robotgo.MaxWindow(fpid[0])
robotgo.CloseWindow(fpid[0])
robotgo.Kill(fpid[0])
}
}
func active() {
robotgo.ActivePid(100)
// robotgo.Sleep(2)
robotgo.ActiveName("code")
robotgo.Sleep(1)
robotgo.ActiveName("chrome")
}
func findName() {
// find the process name by the process id
name, err := robotgo.FindName(100)
if err == nil {
fmt.Println("name: ", name)
}
// find the all process name
names, err := robotgo.FindNames()
if err == nil {
fmt.Println("name: ", names)
}
p, err := robotgo.FindPath(100)
if err == nil {
fmt.Println("path: ", p)
}
}
func ps() {
// determine whether the process exists
isExist, err := robotgo.PidExists(100)
if err == nil && isExist {
fmt.Println("pid exists is", isExist)
robotgo.Kill(100)
}
// get the all process id
pids, err := robotgo.Pids()
if err == nil {
fmt.Println("pids: ", pids)
}
// get the all process struct
ps, err := robotgo.Process()
if err == nil {
fmt.Println("process: ", ps)
}
}
func window() {
////////////////////////////////////////////////////////////////////////////////
// Window Handle
////////////////////////////////////////////////////////////////////////////////
alert()
//
get()
findIds()
active()
findName()
//
ps()
// close current Window
robotgo.CloseWindow()
}
func main() {
window()
}
================================================
FILE: go.mod
================================================
module github.com/go-vgo/robotgo
go 1.24.0
require (
github.com/otiai10/gosseract/v2 v2.4.1
// github.com/robotn/gohook v0.31.3
github.com/robotn/xgb v0.10.0
github.com/robotn/xgbutil v0.10.0
github.com/tailscale/win v0.0.0-20250627215312-f4da2b8ee071
github.com/vcaesar/gops v0.41.0
github.com/vcaesar/imgo v0.41.0
github.com/vcaesar/keycode v0.10.1
github.com/vcaesar/screenshot v0.11.1
github.com/vcaesar/tt v0.20.1
)
require (
github.com/dblohm7/wingoes v0.0.0-20250822163801-6d8e6105c62d // indirect
github.com/ebitengine/purego v0.9.1 // indirect
github.com/gen2brain/shm v0.1.1 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/godbus/dbus/v5 v5.2.0 // indirect
github.com/jezek/xgb v1.2.0 // indirect
github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3 // indirect
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
github.com/shirou/gopsutil/v4 v4.25.10 // indirect
github.com/tklauser/go-sysconf v0.3.16 // indirect
github.com/tklauser/numcpus v0.11.0 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
golang.org/x/exp v0.0.0-20251125195548-87e1e737ad39 // indirect
golang.org/x/image v0.33.0 // indirect
golang.org/x/sys v0.38.0 // indirect
)
// replace golang.org/x/sys => github.com/golang/sys v0.0.0-20190109145017-48ac38b7c8cb
// go 1.13
================================================
FILE: go.sum
================================================
github.com/BurntSushi/freetype-go v0.0.0-20160129220410-b763ddbfe298/go.mod h1:D+QujdIlUNfa0igpNMk6UIvlb6C252URs4yupRUV4lQ=
github.com/BurntSushi/graphics-go v0.0.0-20160129215708-b43f31a4a966/go.mod h1:Mid70uvE93zn9wgF92A/r5ixgnvX8Lh68fxp9KQBaI0=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dblohm7/wingoes v0.0.0-20250822163801-6d8e6105c62d h1:QRKpU+9ZBDs62LyBfwhZkJdB5DJX2Sm3p4kUh7l1aA0=
github.com/dblohm7/wingoes v0.0.0-20250822163801-6d8e6105c62d/go.mod h1:SUxUaAK/0UG5lYyZR1L1nC4AaYYvSSYTWQSH3FPcxKU=
github.com/ebitengine/purego v0.9.1 h1:a/k2f2HQU3Pi399RPW1MOaZyhKJL9w/xFpKAg4q1s0A=
github.com/ebitengine/purego v0.9.1/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
github.com/gen2brain/shm v0.1.1 h1:1cTVA5qcsUFixnDHl14TmRoxgfWEEZlTezpUj1vm5uQ=
github.com/gen2brain/shm v0.1.1/go.mod h1:UgIcVtvmOu+aCJpqJX7GOtiN7X2ct+TKLg4RTxwPIUA=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
github.com/godbus/dbus/v5 v5.2.0 h1:3WexO+U+yg9T70v9FdHr9kCxYlazaAXUhx2VMkbfax8=
github.com/godbus/dbus/v5 v5.2.0/go.mod h1:3AAv2+hPq5rdnr5txxxRwiGjPXamgoIHgz9FPBfOp3c=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/jezek/xgb v1.2.0 h1:LzgkD11wOrPnxXEqo588cnjUt4NwMHrFh/tgajo50Q0=
github.com/jezek/xgb v1.2.0/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk=
github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3 h1:PwQumkgq4/acIiZhtifTV5OUqqiP82UAl0h87xj/l9k=
github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
github.com/otiai10/gosseract/v2 v2.4.1 h1:G8AyBpXEeSlcq8TI85LH/pM5SXk8Djy2GEXisgyblRw=
github.com/otiai10/gosseract/v2 v2.4.1/go.mod h1:1gNWP4Hgr2o7yqWfs6r5bZxAatjOIdqWxJLWsTsembk=
github.com/otiai10/mint v1.6.3 h1:87qsV/aw1F5as1eH1zS/yqHY85ANKVMgkDrf9rcxbQs=
github.com/otiai10/mint v1.6.3/go.mod h1:MJm72SBthJjz8qhefc4z1PYEieWmy8Bku7CjcAqyUSM=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU=
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/robotn/xgb v0.0.0-20190912153532-2cb92d044934/go.mod h1:SxQhJskUJ4rleVU44YvnrdvxQr0tKy5SRSigBrCgyyQ=
github.com/robotn/xgb v0.10.0 h1:O3kFbIwtwZ3pgLbp1h5slCQ4OpY8BdwugJLrUe6GPIM=
github.com/robotn/xgb v0.10.0/go.mod h1:SxQhJskUJ4rleVU44YvnrdvxQr0tKy5SRSigBrCgyyQ=
github.com/robotn/xgbutil v0.10.0 h1:gvf7mGQqCWQ68aHRtCxgdewRk+/KAJui6l3MJQQRCKw=
github.com/robotn/xgbutil v0.10.0/go.mod h1:svkDXUDQjUiWzLrA0OZgHc4lbOts3C+uRfP6/yjwYnU=
github.com/shirou/gopsutil/v4 v4.25.10 h1:at8lk/5T1OgtuCp+AwrDofFRjnvosn0nkN2OLQ6g8tA=
github.com/shirou/gopsutil/v4 v4.25.10/go.mod h1:+kSwyC8DRUD9XXEHCAFjK+0nuArFJM0lva+StQAcskM=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/tailscale/win v0.0.0-20250627215312-f4da2b8ee071 h1:qo7kOhoN5DHioXNlFytBzIoA5glW6lsb8YqV0lP3IyE=
github.com/tailscale/win v0.0.0-20250627215312-f4da2b8ee071/go.mod h1:aMd4yDHLjbOuYP6fMxj1d9ACDQlSWwYztcpybGHCQc8=
github.com/tc-hib/winres v0.2.1 h1:YDE0FiP0VmtRaDn7+aaChp1KiF4owBiJa5l964l5ujA=
github.com/tc-hib/winres v0.2.1/go.mod h1:C/JaNhH3KBvhNKVbvdlDWkbMDO9H4fKKDaN7/07SSuk=
github.com/tklauser/go-sysconf v0.3.16 h1:frioLaCQSsF5Cy1jgRBrzr6t502KIIwQ0MArYICU0nA=
github.com/tklauser/go-sysconf v0.3.16/go.mod h1:/qNL9xxDhc7tx3HSRsLWNnuzbVfh3e7gh/BmM179nYI=
github.com/tklauser/numcpus v0.11.0 h1:nSTwhKH5e1dMNsCdVBukSZrURJRoHbSEQjdEbY+9RXw=
github.com/tklauser/numcpus v0.11.0/go.mod h1:z+LwcLq54uWZTX0u/bGobaV34u6V7KNlTZejzM6/3MQ=
github.com/vcaesar/gops v0.41.0 h1:FG748Jyw3FOuZnbzSgB+CQSx2e5LbLCPWV2JU1brFdc=
github.com/vcaesar/gops v0.41.0/go.mod h1:/3048L7Rj7QjQKTSB+kKc7hDm63YhTWy5QJ10TCP37A=
github.com/vcaesar/imgo v0.41.0 h1:kNLYGrThXhB9Dd6IwFmfPnxq9P6yat2g7dpPjr7OWO8=
github.com/vcaesar/imgo v0.41.0/go.mod h1:/LGOge8etlzaVu/7l+UfhJxR6QqaoX5yeuzGIMfWb4I=
github.com/vcaesar/keycode v0.10.1 h1:0DesGmMAPWpYTCYddOFiCMKCDKgNnwiQa2QXindVUHw=
github.com/vcaesar/keycode v0.10.1/go.mod h1:JNlY7xbKsh+LAGfY2j4M3znVrGEm5W1R8s/Uv6BJcfQ=
github.com/vcaesar/screenshot v0.11.1 h1:GgPuN89XC4Yh38dLx4quPlSo3YiWWhwIria/j3LtrqU=
github.com/vcaesar/screenshot v0.11.1/go.mod h1:gJNwHBiP1v1v7i8TQ4yV1XJtcyn2I/OJL7OziVQkwjs=
github.com/vcaesar/tt v0.20.1 h1:D/jUeeVCNbq3ad8M7hhtB3J9x5RZ6I1n1eZ0BJp7M+4=
github.com/vcaesar/tt v0.20.1/go.mod h1:cH2+AwGAJm19Wa6xvEa+0r+sXDJBT0QgNQey6mwqLeU=
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
golang.org/x/exp v0.0.0-20251125195548-87e1e737ad39 h1:DHNhtq3sNNzrvduZZIiFyXWOL9IWaDPHqTnLJp+rCBY=
golang.org/x/exp v0.0.0-20251125195548-87e1e737ad39/go.mod h1:46edojNIoXTNOhySWIWdix628clX9ODXwPsQuG6hsK0=
golang.org/x/image v0.33.0 h1:LXRZRnv1+zGd5XBUVRFmYEphyyKJjQjCRiOuAP3sZfQ=
golang.org/x/image v0.33.0/go.mod h1:DD3OsTYT9chzuzTQt+zMcOlBHgfoKQb1gry8p76Y1sc=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
================================================
FILE: img.go
================================================
// Copyright (c) 2016-2025 AtomAI, All rights reserved.
//
// See the COPYRIGHT file at the top-level directory of this distribution and at
// https://github.com/go-vgo/robotgo/blob/master/LICENSE
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0>
//
// This file may not be copied, modified, or distributed
// except according to those terms.
package robotgo
import (
"image"
"os/exec"
"unsafe"
"github.com/vcaesar/imgo"
)
// DecodeImg decode the image to image.Image and return
func DecodeImg(path string) (image.Image, string, error) {
return imgo.DecodeFile(path)
}
// OpenImg open the image return []byte
func OpenImg(path string) ([]byte, error) {
return imgo.ImgToBytes(path)
}
// Read read the file return image.Image
func Read(path string) (image.Image, error) {
return imgo.Read(path)
}
// Save create a image file with the image.Image
func Save(img image.Image, path string, quality ...int) error {
return imgo.Save(path, img, quality...)
}
// SaveImg save the image by []byte
func SaveImg(b []byte, path string) error {
return imgo.SaveByte(path, b)
}
// SavePng save the image by image.Image
func SavePng(img image.Image, path string) error {
return imgo.SaveToPNG(path, img)
}
// SaveJpeg save the image by image.Image
func SaveJpeg(img image.Image, path string, quality ...int) error {
return imgo.SaveToJpeg(path, img, quality...)
}
// ToByteImg convert image.Image to []byte
func ToByteImg(img image.Image, fm ...string) []byte {
return imgo.ToByte(img, fm...)
}
// ToStringImg convert image.Image to string
func ToStringImg(img image.Image, fm ...string) string {
return string(ToByteImg(img, fm...))
}
// StrToImg convert base64 string to image.Image
func StrToImg(data string) (image.Image, error) {
return imgo.StrToImg(data)
}
// ByteToImg convert []byte to image.Image
func ByteToImg(b []byte) (image.Image, error) {
return imgo.ByteToImg(b)
}
// ImgSize get the file image size
func ImgSize(path string) (int, int, error) {
return imgo.GetSize(path)
}
// Width return the image.Image width
func Width(img image.Image) int {
return img.Bounds().Max.X
}
// Height return the image.Image height
func Height(img image.Image) int {
return img.Bounds().Max.Y
}
// RGBAToBitmap convert the standard image.RGBA to Bitmap
func RGBAToBitmap(r1 *image.RGBA) (bit Bitmap) {
bit.Width = r1.Bounds().Size().X
bit.Height = r1.Bounds().Size().Y
bit.Bytewidth = r1.Stride
src := ToUint8p(r1.Pix)
bit.ImgBuf = src
bit.BitsPixel = 32
bit.BytesPerPixel = 32 / 8
return
}
// ImgToBitmap convert the standard image.Image to Bitmap
func ImgToBitmap(m image.Image) (bit Bitmap) {
bit.Width = m.Bounds().Size().X
bit.Height = m.Bounds().Size().Y
pix, stride, _ := imgo.EncodeImg(m)
bit.Bytewidth = stride
src := ToUint8p(pix)
bit.ImgBuf = src
//
bit.BitsPixel = 32
bit.BytesPerPixel = 32 / 8
return
}
// ToUint8p convert the []uint8 to uint8 pointer
func ToUint8p(dst []uint8) *uint8 {
src := make([]uint8, len(dst)+10)
for i := 0; i <= len(dst)-4; i += 4 {
src[i+3] = dst[i+3]
src[i] = dst[i+2]
src[i+1] = dst[i+1]
src[i+2] = dst[i]
}
ptr := unsafe.Pointer(&src[0])
return (*uint8)(ptr)
}
// ToRGBAGo convert Bitmap to standard image.RGBA
func ToRGBAGo(bmp1 Bitmap) *image.RGBA {
img1 := image.NewRGBA(image.Rect(0, 0, bmp1.Width, bmp1.Height))
img1.Pix = make([]uint8, bmp1.Bytewidth*bmp1.Height)
copyToVUint8A(img1.Pix, bmp1.ImgBuf)
img1.Stride = bmp1.Bytewidth
return img1
}
func val(p *uint8, n int) uint8 {
addr := uintptr(unsafe.Pointer(p))
addr += uintptr(n)
p1 := (*uint8)(unsafe.Pointer(addr))
return *p1
}
func copyToVUint8A(dst []uint8, src *uint8) {
for i := 0; i <= len(dst)-4; i += 4 {
dst[i] = val(src, i+2)
dst[i+1] = val(src, i+1)
dst[i+2] = val(src, i)
dst[i+3] = val(src, i+3)
}
}
// GetText get the image text by tesseract ocr
//
// robotgo.GetText(imgPath, lang string)
func GetText(imgPath string, args ...string) (string, error) {
var lang = "eng"
if len(args) > 0 {
lang = args[0]
if lang == "zh" {
lang = "chi_sim"
}
}
body, err := exec.Command("tesseract", imgPath,
"stdout", "-l", lang).Output()
if err != nil {
return "", err
}
return string(body), nil
}
================================================
FILE: key/key.go
================================================
// Copyright (c) 2016-2025 AtomAI, All rights reserved.
//
// See the COPYRIGHT file at the top-level directory of this distribution and at
// https://github.com/go-vgo/robotgo/blob/master/LICENSE
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0>
//
// This file may not be copied, modified, or distributed
// except according to those terms.
package key
================================================
FILE: key/key_windows.go
================================================
//go:build windows
// +build windows
package key
================================================
FILE: key/keycode.h
================================================
#pragma once
#ifndef KEYCODE_H
#define KEYCODE_H
#include "../base/os.h"
#if defined(IS_MACOSX)
#include <Carbon/Carbon.h> /* Really only need <HIToolbox/Events.h> */
#include <ApplicationServices/ApplicationServices.h>
#import <IOKit/hidsystem/ev_keymap.h>
enum _MMKeyCode {
// a-z, 0-9
K_NOT_A_KEY = 9999,
K_BACKSPACE = kVK_Delete,
K_DELETE = kVK_ForwardDelete,
K_RETURN = kVK_Return,
K_TAB = kVK_Tab,
K_ESCAPE = kVK_Escape,
K_UP = kVK_UpArrow,
K_DOWN = kVK_DownArrow,
K_RIGHT = kVK_RightArrow,
K_LEFT = kVK_LeftArrow,
K_HOME = kVK_Home,
K_END = kVK_End,
K_PAGEUP = kVK_PageUp,
K_PAGEDOWN = kVK_PageDown,
K_F1 = kVK_F1,
K_F2 = kVK_F2,
K_F3 = kVK_F3,
K_F4 = kVK_F4,
K_F5 = kVK_F5,
K_F6 = kVK_F6,
K_F7 = kVK_F7,
K_F8 = kVK_F8,
K_F9 = kVK_F9,
K_F10 = kVK_F10,
K_F11 = kVK_F11,
K_F12 = kVK_F12,
K_F13 = kVK_F13,
K_F14 = kVK_F14,
K_F15 = kVK_F15,
K_F16 = kVK_F16,
K_F17 = kVK_F17,
K_F18 = kVK_F18,
K_F19 = kVK_F19,
K_F20 = kVK_F20,
K_F21 = K_NOT_A_KEY,
K_F22 = K_NOT_A_KEY,
K_F23 = K_NOT_A_KEY,
K_F24 = K_NOT_A_KEY,
K_META = kVK_Command,
K_LMETA = kVK_Command,
K_RMETA = kVK_RightCommand,
K_ALT = kVK_Option,
K_LALT = kVK_Option,
K_RALT = kVK_RightOption,
K_CONTROL = kVK_Control,
K_LCONTROL = kVK_Control,
K_RCONTROL = kVK_RightControl,
K_SHIFT = kVK_Shift,
K_LSHIFT = kVK_Shift,
K_RSHIFT = kVK_RightShift,
K_CAPSLOCK = kVK_CapsLock,
K_SPACE = kVK_Space,
K_INSERT = kVK_Help,
// K_PRINTSCREEN = K_NOT_A_KEY,
K_PRINTSCREEN = kVK_F13,
K_MENU = K_NOT_A_KEY,
K_NUMPAD_0 = kVK_ANSI_Keypad0,
K_NUMPAD_1 = kVK_ANSI_Keypad1,
K_NUMPAD_2 = kVK_ANSI_Keypad2,
K_NUMPAD_3 = kVK_ANSI_Keypad3,
K_NUMPAD_4 = kVK_ANSI_Keypad4,
K_NUMPAD_5 = kVK_ANSI_Keypad5,
K_NUMPAD_6 = kVK_ANSI_Keypad6,
K_NUMPAD_7 = kVK_ANSI_Keypad7,
K_NUMPAD_8 = kVK_ANSI_Keypad8,
K_NUMPAD_9 = kVK_ANSI_Keypad9,
K_NUMPAD_LOCK = kVK_ANSI_KeypadClear,
//
K_NUMPAD_DECIMAL = kVK_ANSI_KeypadDecimal,
K_NUMPAD_PLUS = kVK_ANSI_KeypadPlus,
K_NUMPAD_MINUS = kVK_ANSI_KeypadMinus,
K_NUMPAD_MUL = kVK_ANSI_KeypadMultiply,
K_NUMPAD_DIV = kVK_ANSI_KeypadDivide,
K_NUMPAD_CLEAR = kVK_ANSI_KeypadClear,
K_NUMPAD_ENTER = kVK_ANSI_KeypadEnter,
K_NUMPAD_EQUAL = kVK_ANSI_KeypadEquals,
K_NUMPAD_LB = kVK_ANSI_LeftBracket,
K_NUMPAD_RB = kVK_ANSI_RightBracket,
K_Backslash = kVK_ANSI_Backslash,
K_Semicolon = kVK_ANSI_Semicolon,
K_Quote = kVK_ANSI_Quote,
K_Slash = kVK_ANSI_Slash,
K_Grave = kVK_ANSI_Grave,
K_AUDIO_VOLUME_MUTE = 1007,
K_AUDIO_VOLUME_DOWN = 1001,
K_AUDIO_VOLUME_UP = 1000,
K_AUDIO_PLAY = 1016,
K_AUDIO_STOP = K_NOT_A_KEY,
K_AUDIO_PAUSE = 1016,
K_AUDIO_PREV = 1018,
K_AUDIO_NEXT = 1017,
K_AUDIO_REWIND = K_NOT_A_KEY,
K_AUDIO_FORWARD = K_NOT_A_KEY,
K_AUDIO_REPEAT = K_NOT_A_KEY,
K_AUDIO_RANDOM = K_NOT_A_KEY,
K_LIGHTS_MON_UP = 1002,
K_LIGHTS_MON_DOWN = 1003,
K_LIGHTS_KBD_TOGGLE = 1023,
K_LIGHTS_KBD_UP = 1021,
K_LIGHTS_KBD_DOWN = 1022
};
typedef CGKeyCode MMKeyCode;
#elif defined(USE_X11)
#include <X11/Xutil.h>
#include <X11/XF86keysym.h>
enum _MMKeyCode {
K_NOT_A_KEY = 9999,
K_BACKSPACE = XK_BackSpace,
K_DELETE = XK_Delete,
K_RETURN = XK_Return,
K_TAB = XK_Tab,
K_ESCAPE = XK_Escape,
K_UP = XK_Up,
K_DOWN = XK_Down,
K_RIGHT = XK_Right,
K_LEFT = XK_Left,
K_HOME = XK_Home,
K_END = XK_End,
K_PAGEUP = XK_Page_Up,
K_PAGEDOWN = XK_Page_Down,
K_F1 = XK_F1,
K_F2 = XK_F2,
K_F3 = XK_F3,
K_F4 = XK_F4,
K_F5 = XK_F5,
K_F6 = XK_F6,
K_F7 = XK_F7,
K_F8 = XK_F8,
K_F9 = XK_F9,
K_F10 = XK_F10,
K_F11 = XK_F11,
K_F12 = XK_F12,
K_F13 = XK_F13,
K_F14 = XK_F14,
K_F15 = XK_F15,
K_F16 = XK_F16,
K_F17 = XK_F17,
K_F18 = XK_F18,
K_F19 = XK_F19,
K_F20 = XK_F20,
K_F21 = XK_F21,
K_F22 = XK_F22,
K_F23 = XK_F23,
K_F24 = XK_F24,
K_META = XK_Super_L,
K_LMETA = XK_Super_L,
K_RMETA = XK_Super_R,
K_ALT = XK_Alt_L,
K_LALT = XK_Alt_L,
K_RALT = XK_Alt_R,
K_CONTROL = XK_Control_L,
K_LCONTROL = XK_Control_L,
K_RCONTROL = XK_Control_R,
K_SHIFT = XK_Shift_L,
K_LSHIFT = XK_Shift_L,
K_RSHIFT = XK_Shift_R,
K_CAPSLOCK = XK_Caps_Lock,
K_SPACE = XK_space,
K_INSERT = XK_Insert,
K_PRINTSCREEN = XK_Print,
K_MENU = K_NOT_A_KEY,
// K_NUMPAD_0 = K_NOT_A_KEY,
K_NUMPAD_0 = XK_KP_0,
K_NUMPAD_1 = XK_KP_1,
K_NUMPAD_2 = XK_KP_2,
K_NUMPAD_3 = XK_KP_3,
K_NUMPAD_4 = XK_KP_4,
K_NUMPAD_5 = XK_KP_5,
K_NUMPAD_6 = XK_KP_6,
K_NUMPAD_7 = XK_KP_7,
K_NUMPAD_8 = XK_KP_8,
K_NUMPAD_9 = XK_KP_9,
K_NUMPAD_LOCK = XK_Num_Lock,
//
K_NUMPAD_DECIMAL = XK_KP_Decimal,
K_NUMPAD_PLUS = 78, // XK_KP_Add
K_NUMPAD_MINUS = 74, // XK_KP_Subtract
K_NUMPAD_MUL = 55, // XK_KP_Multiply
K_NUMPAD_DIV = 98, // XK_KP_Divide
K_NUMPAD_CLEAR = K_NOT_A_KEY,
K_NUMPAD_ENTER = 96, // XK_KP_Enter
K_NUMPAD_EQUAL = XK_equal,
K_NUMPAD_LB = XK_bracketleft,
K_NUMPAD_RB = XK_bracketright,
K_Backslash = XK_backslash,
K_Semicolon = XK_semicolon,
K_Quote = XK_apostrophe,
K_Slash = XK_slash,
K_Grave = XK_grave,
K_AUDIO_VOLUME_MUTE = XF86XK_AudioMute,
K_AUDIO_VOLUME_DOWN = XF86XK_AudioLowerVolume,
K_AUDIO_VOLUME_UP = XF86XK_AudioRaiseVolume,
K_AUDIO_PLAY = XF86XK_AudioPlay,
K_AUDIO_STOP = XF86XK_AudioStop,
K_AUDIO_PAUSE = XF86XK_AudioPause,
K_AUDIO_PREV = XF86XK_AudioPrev,
K_AUDIO_NEXT = XF86XK_AudioNext,
K_AUDIO_REWIND = XF86XK_AudioRewind,
K_AUDIO_FORWARD = XF86XK_AudioForward,
K_AUDIO_REPEAT = XF86XK_AudioRepeat,
K_AUDIO_RANDOM = XF86XK_AudioRandomPlay,
K_LIGHTS_MON_UP = XF86XK_MonBrightnessUp,
K_LIGHTS_MON_DOWN = XF86XK_MonBrightnessDown,
K_LIGHTS_KBD_TOGGLE = XF86XK_KbdLightOnOff,
K_LIGHTS_KBD_UP = XF86XK_KbdBrightnessUp,
K_LIGHTS_KBD_DOWN = XF86XK_KbdBrightnessDown
};
typedef KeySym MMKeyCode;
/*
* Structs to store key mappings not handled by XStringToKeysym() on some
* Linux systems.
*/
struct XSpecialCharacterMapping {
char name;
MMKeyCode code;
};
struct XSpecialCharacterMapping XSpecialCharacterTable[] = {
{'~', XK_asciitilde},
{'_', XK_underscore},
{'[', XK_bracketleft},
{']', XK_bracketright},
{'!', XK_exclam},
{'#', XK_numbersign},
{'$', XK_dollar},
{'%', XK_percent},
{'&', XK_ampersand},
{'*', XK_asterisk},
{'+', XK_plus},
{',', XK_comma},
{'-', XK_minus},
{'.', XK_period},
{'?', XK_question},
{'<', XK_less},
{'>', XK_greater},
{'=', XK_equal},
{'@', XK_at},
{':', XK_colon},
{';', XK_semicolon},
{'{', XK_braceleft},
{'}', XK_braceright},
{'|', XK_bar},
{'^', XK_asciicircum},
{'(', XK_parenleft},
{')', XK_parenright},
{' ', XK_space},
{'/', XK_slash},
{'\\', XK_backslash},
{'`', XK_grave},
{'"', XK_quoteright},
{'\'', XK_quotedbl},
{'\t', XK_Tab},
{'\n', XK_Return}
};
#elif defined(IS_WINDOWS)
enum _MMKeyCode {
K_NOT_A_KEY = 9999,
K_BACKSPACE = VK_BACK,
K_DELETE = VK_DELETE,
K_RETURN = VK_RETURN,
K_TAB = VK_TAB,
K_ESCAPE = VK_ESCAPE,
K_UP = VK_UP,
K_DOWN = VK_DOWN,
K_RIGHT = VK_RIGHT,
K_LEFT = VK_LEFT,
K_HOME = VK_HOME,
K_END = VK_END,
K_PAGEUP = VK_PRIOR,
K_PAGEDOWN = VK_NEXT,
K_F1 = VK_F1,
K_F2 = VK_F2,
K_F3 = VK_F3,
K_F4 = VK_F4,
K_F5 = VK_F5,
K_F6 = VK_F6,
K_F7 = VK_F7,
K_F8 = VK_F8,
K_F9 = VK_F9,
K_F10 = VK_F10,
K_F11 = VK_F11,
K_F12 = VK_F12,
K_F13 = VK_F13,
K_F14 = VK_F14,
K_F15 = VK_F15,
K_F16 = VK_F16,
K_F17 = VK_F17,
K_F18 = VK_F18,
K_F19 = VK_F19,
K_F20 = VK_F20,
K_F21 = VK_F21,
K_F22 = VK_F22,
K_F23 = VK_F23,
K_F24 = VK_F24,
K_META = VK_LWIN,
K_LMETA = VK_LWIN,
K_RMETA = VK_RWIN,
K_ALT = VK_MENU,
K_LALT = VK_LMENU,
K_RALT = VK_RMENU,
K_CONTROL = VK_CONTROL,
K_LCONTROL = VK_LCONTROL,
K_RCONTROL = VK_RCONTROL,
K_SHIFT = VK_SHIFT,
K_LSHIFT = VK_LSHIFT,
K_RSHIFT = VK_RSHIFT,
K_CAPSLOCK = VK_CAPITAL,
K_SPACE = VK_SPACE,
K_PRINTSCREEN = VK_SNAPSHOT,
K_INSERT = VK_INSERT,
K_MENU = VK_APPS,
K_NUMPAD_0 = VK_NUMPAD0,
K_NUMPAD_1 = VK_NUMPAD1,
K_NUMPAD_2 = VK_NUMPAD2,
K_NUMPAD_3 = VK_NUMPAD3,
K_NUMPAD_4 = VK_NUMPAD4,
K_NUMPAD_5 = VK_NUMPAD5,
K_NUMPAD_6 = VK_NUMPAD6,
K_NUMPAD_7 = VK_NUMPAD7,
K_NUMPAD_8 = VK_NUMPAD8,
K_NUMPAD_9 = VK_NUMPAD9,
K_NUMPAD_LOCK = VK_NUMLOCK,
// VK_NUMPAD_
K_NUMPAD_DECIMAL = VK_DECIMAL,
K_NUMPAD_PLUS = VK_ADD,
K_NUMPAD_MINUS = VK_SUBTRACT,
K_NUMPAD_MUL = VK_MULTIPLY,
K_NUMPAD_DIV = VK_DIVIDE,
K_NUMPAD_CLEAR = K_NOT_A_KEY,
K_NUMPAD_ENTER = VK_RETURN,
K_NUMPAD_EQUAL = VK_OEM_PLUS,
K_NUMPAD_LB = VK_OEM_4,
K_NUMPAD_RB = VK_OEM_6,
K_Backslash = VK_OEM_5,
K_Semicolon = VK_OEM_1,
K_Quote = VK_OEM_7,
K_Slash = VK_OEM_2,
K_Grave = VK_OEM_3,
K_AUDIO_VOLUME_MUTE = VK_VOLUME_MUTE,
K_AUDIO_VOLUME_DOWN = VK_VOLUME_DOWN,
K_AUDIO_VOLUME_UP = VK_VOLUME_UP,
K_AUDIO_PLAY = VK_MEDIA_PLAY_PAUSE,
K_AUDIO_STOP = VK_MEDIA_STOP,
K_AUDIO_PAUSE = VK_MEDIA_PLAY_PAUSE,
K_AUDIO_PREV = VK_MEDIA_PREV_TRACK,
K_AUDIO_NEXT = VK_MEDIA_NEXT_TRACK,
K_AUDIO_REWIND = K_NOT_A_KEY,
K_AUDIO_FORWARD = K_NOT_A_KEY,
K_AUDIO_REPEAT = K_NOT_A_KEY,
K_AUDIO_RANDOM = K_NOT_A_KEY,
K_LIGHTS_MON_UP = K_NOT_A_KEY,
K_LIGHTS_MON_DOWN = K_NOT_A_KEY,
K_LIGHTS_KBD_TOGGLE = K_NOT_A_KEY,
K_LIGHTS_KBD_UP = K_NOT_A_KEY,
K_LIGHTS_KBD_DOWN = K_NOT_A_KEY
};
typedef int MMKeyCode;
#endif
/* Returns the keyCode corresponding to the current keyboard layout for the
* given ASCII character. */
MMKeyCode keyCodeForChar(const char c);
#endif /* KEYCODE_H */
================================================
FILE: key/keycode_c.h
================================================
#include "keycode.h"
#if defined(IS_MACOSX)
#include <CoreFoundation/CoreFoundation.h>
#include <Carbon/Carbon.h> /* For kVK_ constants, and TIS functions. */
/* Returns string representation of key, if it is printable.
Ownership follows the Create Rule;
it is the caller's responsibility to release the returned object. */
CFStringRef createStringForKey(CGKeyCode keyCode);
#endif
MMKeyCode keyCodeForChar(const char c) {
#if defined(IS_MACOSX)
/* OS X does not appear to have a built-in function for this,
so instead it to write our own. */
static CFMutableDictionaryRef charToCodeDict = NULL;
CGKeyCode code;
UniChar character = c;
CFStringRef charStr = NULL;
/* Generate table of keycodes and characters. */
if (charToCodeDict == NULL) {
size_t i;
charToCodeDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 128,
&kCFCopyStringDictionaryKeyCallBacks, NULL);
if (charToCodeDict == NULL) { return K_NOT_A_KEY; }
/* Loop through every keycode (0 - 127) to find its current mapping. */
for (i = 0; i < 128; ++i) {
CFStringRef string = createStringForKey((CGKeyCode)i);
if (string != NULL) {
CFDictionaryAddValue(charToCodeDict, string, (const void *)i);
CFRelease(string);
}
}
}
charStr = CFStringCreateWithCharacters(kCFAllocatorDefault, &character, 1);
/* Our values may be NULL (0), so we need to use this function. */
/* Use pointer-sized variable to avoid stack overflow on 64-bit systems */
const void *codePtr = NULL;
if (!CFDictionaryGetValueIfPresent(charToCodeDict, charStr, &codePtr)) {
code = UINT16_MAX; /* Error */
} else {
code = (CGKeyCode)(uintptr_t)codePtr;
}
CFRelease(charStr);
// TISGetInputSourceProperty may return nil so we need fallback
if (code == UINT16_MAX) {
return K_NOT_A_KEY;
}
return (MMKeyCode)code;
#elif defined(IS_WINDOWS)
MMKeyCode code;
code = VkKeyScan(c);
if (code == 0xFFFF) {
return K_NOT_A_KEY;
}
return code;
#elif defined(USE_X11)
char buf[2];
buf[0] = c;
buf[1] = '\0';
MMKeyCode code = XStringToKeysym(buf);
if (code == NoSymbol) {
/* Some special keys are apparently not handled properly */
struct XSpecialCharacterMapping* xs = XSpecialCharacterTable;
while (xs->name) {
if (c == xs->name) {
code = xs->code;
//
break;
}
xs++;
}
}
if (code == NoSymbol) {
return K_NOT_A_KEY;
}
// x11 key bug
if (c == 60) {
code = 44;
}
return code;
#endif
}
#if defined(IS_MACOSX)
CFStringRef createStringForKey(CGKeyCode keyCode){
// TISInputSourceRef currentKeyboard = TISCopyCurrentASCIICapableKeyboardInputSource();
TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardLayoutInputSource();
/* Check if currentKeyboard is NULL to avoid crash */
if (currentKeyboard == NULL) { return NULL; }
CFDataRef layoutData = (CFDataRef) TISGetInputSourceProperty(
currentKeyboard, kTISPropertyUnicodeKeyLayoutData);
if (layoutData == nil) {
CFRelease(currentKeyboard); /* Fix memory leak */
return NULL;
}
const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout *) CFDataGetBytePtr(layoutData);
UInt32 keysDown = 0;
UniChar chars[4];
UniCharCount realLength;
UCKeyTranslate(keyboardLayout, keyCode, kUCKeyActionDisplay, 0, LMGetKbdType(),
kUCKeyTranslateNoDeadKeysBit, &keysDown,
sizeof(chars) / sizeof(chars[0]), &realLength, chars);
CFRelease(currentKeyboard);
return CFStringCreateWithCharacters(kCFAllocatorDefault, chars, 1);
}
#endif
================================================
FILE: key/keypress.h
================================================
#pragma once
#ifndef KEYPRESS_H
#define KEYPRESS_H
#include <stdlib.h>
#include "../base/os.h"
#include "../base/types.h"
#include "keycode.h"
#include <stdbool.h>
#if defined(IS_MACOSX)
typedef enum {
MOD_NONE = 0,
MOD_META = kCGEventFlagMaskCommand,
MOD_ALT = kCGEventFlagMaskAlternate,
MOD_CONTROL = kCGEventFlagMaskControl,
MOD_SHIFT = kCGEventFlagMaskShift
} MMKeyFlags;
#elif defined(USE_X11)
enum _MMKeyFlags {
MOD_NONE = 0,
MOD_META = Mod4Mask,
MOD_ALT = Mod1Mask,
MOD_CONTROL = ControlMask,
MOD_SHIFT = ShiftMask
};
typedef unsigned int MMKeyFlags;
#elif defined(IS_WINDOWS)
enum _MMKeyFlags {
MOD_NONE = 0,
/* These are already defined by the Win32 API */
/* MOD_ALT = 0,
MOD_CONTROL = 0,
MOD_SHIFT = 0, */
MOD_META = MOD_WIN
};
typedef unsigned int MMKeyFlags;
#endif
#if defined(IS_WINDOWS)
/* Send win32 key event for given key. */
void win32KeyEvent(int key, MMKeyFlags flags, uintptr pid, int8_t isPid);
#endif
#endif /* KEYPRESS_H */
================================================
FILE: key/keypress_c.h
================================================
// Copyright (c) 2016-2025 AtomAI, All rights reserved.
//
// See the COPYRIGHT file at the top-level directory of this distribution and at
// https://github.com/go-vgo/robotgo/blob/master/LICENSE
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0>
//
// This file may not be copied, modified, or distributed
// except according to those terms.
#include "../base/deadbeef_rand_c.h"
#include "../base/microsleep.h"
#include "keypress.h"
#include "keycode_c.h"
#include <ctype.h> /* For isupper() */
#if defined(IS_MACOSX)
#include <ApplicationServices/ApplicationServices.h>
#import <IOKit/hidsystem/IOHIDLib.h>
#import <IOKit/hidsystem/ev_keymap.h>
#elif defined(USE_X11)
#include <X11/extensions/XTest.h>
// #include "../base/xdisplay_c.h"
#endif
/* Convenience wrappers around ugly APIs. */
#if defined(IS_WINDOWS)
HWND GetHwndByPid(DWORD dwProcessId);
HWND getHwnd(uintptr pid, int8_t isPid) {
HWND hwnd = (HWND) pid;
if (isPid == 0) {
hwnd = GetHwndByPid(pid);
}
return hwnd;
}
void WIN32_KEY_EVENT_WAIT(MMKeyCode key, DWORD flags, uintptr pid) {
win32KeyEvent(key, flags, pid, 0);
Sleep(DEADBEEF_RANDRANGE(0, 1));
}
#elif defined(USE_X11)
Display *XGetMainDisplay(void);
void X_KEY_EVENT(Display *display, MMKeyCode key, bool is_press) {
XTestFakeKeyEvent(display, XKeysymToKeycode(display, key), is_press, CurrentTime);
XSync(display, false);
}
void X_KEY_EVENT_WAIT(Display *display, MMKeyCode key, bool is_press) {
X_KEY_EVENT(display, key, is_press);
microsleep(DEADBEEF_UNIFORM(0.0, 0.5));
}
#endif
#if defined(IS_MACOSX)
int SendTo(uintptr pid, CGEventRef event) {
if (pid != 0) {
CGEventPostToPid(pid, event);
} else {
CGEventPost(kCGHIDEventTap, event);
}
CFRelease(event);
return 0;
}
static io_connect_t _getAuxiliaryKeyDriver(void) {
static mach_port_t sEventDrvrRef = 0;
mach_port_t masterPort, service, iter;
kern_return_t kr;
if (!sEventDrvrRef) {
kr = IOMasterPort(bootstrap_port, &masterPort);
assert(KERN_SUCCESS == kr);
kr = IOServiceGetMatchingServices(masterPort, IOServiceMatching(kIOHIDSystemClass), &iter);
assert(KERN_SUCCESS == kr);
service = IOIteratorNext(iter);
assert(service);
kr = IOServiceOpen(service, mach_task_self(), kIOHIDParamConnectType, &sEventDrvrRef);
assert(KERN_SUCCESS == kr);
IOObjectRelease(service);
IOObjectRelease(iter);
}
return sEventDrvrRef;
}
#elif defined(IS_WINDOWS)
void win32KeyEvent(int key, MMKeyFlags flags, uintptr pid, int8_t isPid) {
int scan = MapVirtualKey(key & 0xff, MAPVK_VK_TO_VSC);
/* Set the scan code for extended keys */
switch (key){
case VK_RCONTROL:
case VK_SNAPSHOT: /* Print Screen */
case VK_RMENU: /* Right Alt / Alt Gr */
case VK_PAUSE: /* Pause / Break */
case VK_HOME:
case VK_UP:
case VK_PRIOR: /* Page up */
case VK_LEFT:
case VK_RIGHT:
case VK_END:
case VK_DOWN:
case VK_NEXT: /* 'Page Down' */
case VK_INSERT:
case VK_DELETE:
case VK_LWIN:
case VK_RWIN:
case VK_APPS: /* Application */
case VK_VOLUME_MUTE:
case VK_VOLUME_DOWN:
case VK_VOLUME_UP:
case VK_MEDIA_NEXT_TRACK:
case VK_MEDIA_PREV_TRACK:
case VK_MEDIA_STOP:
case VK_MEDIA_PLAY_PAUSE:
case VK_BROWSER_BACK:
case VK_BROWSER_FORWARD:
case VK_BROWSER_REFRESH:
case VK_BROWSER_STOP:
case VK_BROWSER_SEARCH:
case VK_BROWSER_FAVORITES:
case VK_BROWSER_HOME:
case VK_LAUNCH_MAIL:
{
flags |= KEYEVENTF_EXTENDEDKEY;
break;
}
}
// todo: test this
if (pid != 0) {
HWND hwnd = getHwnd(pid, isPid);
int down = (flags == 0 ? WM_KEYDOWN : WM_KEYUP);
// SendMessage(hwnd, down, key, 0);
PostMessageW(hwnd, down, key, 0);
return;
}
/* Set the scan code for keyup */
// if ( flags & KEYEVENTF_KEYUP ) {
// scan |= 0x80;
// }
// keybd_event(key, scan, flags, 0);
INPUT keyInput;
keyInput.type = INPUT_KEYBOARD;
keyInput.ki.wVk = key;
keyInput.ki.wScan = scan;
keyInput.ki.dwFlags = flags;
keyInput.ki.time = 0;
keyInput.ki.dwExtraInfo = 0;
SendInput(1, &keyInput, sizeof(keyInput));
}
#endif
void toggleKeyCode(MMKeyCode code, const bool down, MMKeyFlags flags, uintptr pid) {
#if defined(IS_MACOSX)
/* The media keys all have 1000 added to them to help us detect them. */
if (code >= 1000) {
code = code - 1000; /* Get the real keycode. */
NXEventData event;
kern_return_t kr;
IOGPoint loc = { 0, 0 };
UInt32 evtInfo = code << 16 | (down?NX_KEYDOWN:NX_KEYUP) << 8;
bzero(&event, sizeof(NXEventData));
event.compound.subType = NX_SUBTYPE_AUX_CONTROL_BUTTONS;
event.compound.misc.L[0] = evtInfo;
kr = IOHIDPostEvent(_getAuxiliaryKeyDriver(),
NX_SYSDEFINED, loc, &event, kNXEventDataVersion, 0, FALSE);
assert(KERN_SUCCESS == kr);
} else {
CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
CGEventRef keyEvent = CGEventCreateKeyboardEvent(source, (CGKeyCode)code, down);
assert(keyEvent != NULL);
CGEventSetType(keyEvent, down ? kCGEventKeyDown : kCGEventKeyUp);
if (flags != 0) {
CGEventSetFlags(keyEvent, (CGEventFlags) flags);
}
SendTo(pid, keyEvent);
CFRelease(source);
}
#elif defined(IS_WINDOWS)
const DWORD dwFlags = down ? 0 : KEYEVENTF_KEYUP;
/* Parse modifier keys. */
if (flags & MOD_META) { WIN32_KEY_EVENT_WAIT(K_META, dwFlags, pid); }
if (flags & MOD_ALT) { WIN32_KEY_EVENT_WAIT(K_ALT, dwFlags, pid); }
if (flags & MOD_CONTROL) { WIN32_KEY_EVENT_WAIT(K_CONTROL, dwFlags, pid); }
if (flags & MOD_SHIFT) { WIN32_KEY_EVENT_WAIT(K_SHIFT, dwFlags, pid); }
win32KeyEvent(code, dwFlags, pid, 0);
#elif defined(USE_X11)
Display *display = XGetMainDisplay();
const Bool is_press = down ? True : False; /* Just to be safe. */
/* Parse modifier keys. */
if (flags & MOD_META) { X_KEY_EVENT_WAIT(display, K_META, is_press); }
if (flags & MOD_ALT) { X_KEY_EVENT_WAIT(display, K_ALT, is_press); }
if (flags & MOD_CONTROL) { X_KEY_EVENT_WAIT(display, K_CONTROL, is_press); }
if (flags & MOD_SHIFT) { X_KEY_EVENT_WAIT(display, K_SHIFT, is_press); }
X_KEY_EVENT(display, code, is_press);
#endif
}
// void tapKeyCode(MMKeyCode code, MMKeyFlags flags){
// toggleKeyCode(code, true, flags);
// microsleep(5.0);
// toggleKeyCode(code, false, flags);
// }
#if defined(USE_X11)
bool toUpper(char c) {
if (isupper(c)) {
return true;
}
char *special = "~!@#$%^&*()_+{}|:\"<>?";
while (*special) {
if (*special == c) {
return true;
}
special++;
}
return false;
}
#endif
void toggleKey(char c, const bool down, MMKeyFlags flags, uintptr pid) {
MMKeyCode keyCode = keyCodeForChar(c);
#if defined(USE_X11)
if (toUpper(c) && !(flags & MOD_SHIFT)) {
flags |= MOD_SHIFT; /* Not sure if this is safe for all layouts. */
}
#else
if (isupper(c) && !(flags & MOD_SHIFT)) {
flags |= MOD_SHIFT; /* Not sure if this is safe for all layouts. */
}
#endif
#if defined(IS_WINDOWS)
int modifiers = keyCode >> 8; // Pull out modifers.
if ((modifiers & 1) != 0) { flags |= MOD_SHIFT; } // Uptdate flags from keycode modifiers.
if ((modifiers & 2) != 0) { flags |= MOD_CONTROL; }
if ((modifiers & 4) != 0) { flags |= MOD_ALT; }
keyCode = keyCode & 0xff; // Mask out modifiers.
#endif
toggleKeyCode(keyCode, down, flags, pid);
}
// void tapKey(char c, MMKeyFlags flags){
// toggleKey(c, true, flags);
// microsleep(5.0);
// toggleKey(c, false, flags);
// }
#if defined(IS_MACOSX)
void toggleUnicode(UniChar ch, const bool down, uintptr pid) {
/* This function relies on the convenient CGEventKeyboardSetUnicodeString(),
convert characters to a keycode, but does not support adding modifier flags.
It is only used in typeString().
-- if you need modifier keys, use the above functions instead. */
CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
CGEventRef keyEvent = CGEventCreateKeyboardEvent(source, 0, down);
if (keyEvent == NULL) {
fputs("Could not create keyboard event.\n", stderr);
return;
}
CGEventKeyboardSetUnicodeString(keyEvent, 1, &ch);
SendTo(pid, keyEvent);
CFRelease(source);
}
#else
#define toggleUniKey(c, down) toggleKey(c, down, MOD_NONE, 0)
#endif
// unicode type
void unicodeType(const unsigned value, uintptr pid, int8_t isPid) {
#if defined(IS_MACOSX)
UniChar ch = (UniChar)value; // Convert to unsigned char
toggleUnicode(ch, true, pid);
microsleep(5.0);
toggleUnicode(ch, false, pid);
#elif defined(IS_WINDOWS)
if (pid != 0) {
HWND hwnd = getHwnd(pid, isPid);
// SendMessage(hwnd, down, value, 0);
PostMessageW(hwnd, WM_CHAR, value, 0);
return;
}
INPUT input[2];
memset(input, 0, sizeof(input));
input[0].type = INPUT_KEYBOARD;
input[0].ki.wVk = 0;
input[0].ki.wScan = value;
input[0].ki.dwFlags = 0x4; // KEYEVENTF_UNICODE;
input[1].type = INPUT_KEYBOARD;
input[1].ki.wVk = 0;
input[1].ki.wScan = value;
input[1].ki.dwFlags = KEYEVENTF_KEYUP | 0x4; // KEYEVENTF_UNICODE;
SendInput(2, input, sizeof(INPUT));
#elif defined(USE_X11)
toggleUniKey(value, true);
microsleep(5.0);
toggleUniKey(value, false);
#endif
}
#if defined(USE_X11)
int input_utf(const char *utf) {
Display *dpy = XOpenDisplay(NULL);
KeySym sym = XStringToKeysym(utf);
// KeySym sym = XKeycodeToKeysym(dpy, utf);
int min, max, numcodes;
XDisplayKeycodes(dpy, &min, &max);
KeySym *keysym;
keysym = XGetKeyboardMapping(dpy, min, max-min+1, &numcodes);
keysym[(max-min-1)*numcodes] = sym;
XChangeKeyboardMapping(dpy, min, numcodes, keysym, (max-min));
XFree(keysym);
XFlush(dpy);
KeyCode code = XKeysymToKeycode(dpy, sym);
XTestFakeKeyEvent(dpy, code, True, 1);
XTestFakeKeyEvent(dpy, code, False, 1);
XFlush(dpy);
XCloseDisplay(dpy);
return 0;
}
#else
int input_utf(const char *utf){
return 0;
}
#endif
================================================
FILE: key.go
================================================
// Copyright (c) 2016-2025 AtomAI, All rights reserved.
//
// See the COPYRIGHT file at the top-level directory of this distribution and at
// https://github.com/go-vgo/robotgo/blob/master/LICENSE
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0>
//
// This file may not be copied, modified, or distributed
// except according to those terms.
package robotgo
/*
// #include "key/keycode.h"
#include "key/keypress_c.h"
*/
import "C"
import (
"errors"
"math/rand"
"reflect"
"runtime"
"strconv"
"strings"
"unicode"
"unsafe"
"github.com/go-vgo/robotgo/clipboard"
)
// Defining a bunch of constants.
const (
// KeyA define key "a"
KeyA = "a"
KeyB = "b"
KeyC = "c"
KeyD = "d"
KeyE = "e"
KeyF = "f"
KeyG = "g"
KeyH = "h"
KeyI = "i"
KeyJ = "j"
KeyK = "k"
KeyL = "l"
KeyM = "m"
KeyN = "n"
KeyO = "o"
KeyP = "p"
KeyQ = "q"
KeyR = "r"
KeyS = "s"
KeyT = "t"
KeyU = "u"
KeyV = "v"
KeyW = "w"
KeyX = "x"
KeyY = "y"
KeyZ = "z"
//
CapA = "A"
CapB = "B"
CapC = "C"
CapD = "D"
CapE = "E"
CapF = "F"
CapG = "G"
CapH = "H"
CapI = "I"
CapJ = "J"
CapK = "K"
CapL = "L"
CapM = "M"
CapN = "N"
CapO = "O"
CapP = "P"
CapQ = "Q"
CapR = "R"
CapS = "S"
CapT = "T"
CapU = "U"
CapV = "V"
CapW = "W"
CapX = "X"
CapY = "Y"
CapZ = "Z"
//
Key0 = "0"
Key1 = "1"
Key2 = "2"
Key3 = "3"
Key4 = "4"
Key5 = "5"
Key6 = "6"
Key7 = "7"
Key8 = "8"
Key9 = "9"
KeyGrave = "`"
KeyQuoter = '"'
KeyQuote = "'"
// Backspace backspace key string
Backspace = "backspace"
Delete = "delete"
Enter = "enter"
Tab = "tab"
Esc = "esc"
Escape = "escape"
Up = "up" // Up arrow key
Down = "down" // Down arrow key
Right = "right" // Right arrow key
Left = "left" // Left arrow key
Home = "home"
End = "end"
Pageup = "pageup"
Pagedown = "pagedown"
F1 = "f1"
F2 = "f2"
F3 = "f3"
F4 = "f4"
F5 = "f5"
F6 = "f6"
F7 = "f7"
F8 = "f8"
F9 = "f9"
F10 = "f10"
F11 = "f11"
F12 = "f12"
F13 = "f13"
F14 = "f14"
F15 = "f15"
F16 = "f16"
F17 = "f17"
F18 = "f18"
F19 = "f19"
F20 = "f20"
F21 = "f21"
F22 = "f22"
F23 = "f23"
F24 = "f24"
Cmd = "cmd" // is the "win" key for windows
Lcmd = "lcmd" // left command
Rcmd = "rcmd" // right command
// "command"
Alt = "alt"
Lalt = "lalt" // left alt
Ralt = "ralt" // right alt
Ctrl = "ctrl"
Lctrl = "lctrl" // left ctrl
Rctrl = "rctrl" // right ctrl
Control = "control"
Shift = "shift"
Lshift = "lshift" // left shift
Rshift = "rshift" // right shift
// "right_shift"
Capslock = "capslock"
Space = "space"
Print = "print"
Printscreen = "printscreen" // No Mac support
Insert = "insert"
Menu = "menu" // Windows only
AudioMute = "audio_mute" // Mute the volume
AudioVolDown = "audio_vol_down" // Lower the volume
AudioVolUp = "audio_vol_up" // Increase the volume
AudioPlay = "audio_play"
AudioStop = "audio_stop"
AudioPause = "audio_pause"
AudioPrev = "audio_prev" // Previous Track
AudioNext = "audio_next" // Next Track
AudioRewind = "audio_rewind" // Linux only
AudioForward = "audio_forward" // Linux only
AudioRepeat = "audio_repeat" // Linux only
AudioRandom = "audio_random" // Linux only
Num0 = "num0" // numpad 0
Num1 = "num1"
Num2 = "num2"
Num3 = "num3"
Num4 = "num4"
Num5 = "num5"
Num6 = "num6"
Num7 = "num7"
Num8 = "num8"
Num9 = "num9"
NumLock = "num_lock"
NumDecimal = "num."
NumPlus = "num+"
NumMinus = "num-"
NumMul = "num*"
NumDiv = "num/"
NumClear = "num_clear"
NumEnter = "num_enter"
NumEqual = "num_equal"
LightsMonUp = "lights_mon_up" // Turn up monitor brightness No Windows support
LightsMonDown = "lights_mon_down" // Turn down monitor brightness No Windows support
LightsKbdToggle = "lights_kbd_toggle" // Toggle keyboard backlight on/off No Windows support
LightsKbdUp = "lights_kbd_up" // Turn up keyboard backlight brightness No Windows support
LightsKbdDown = "lights_kbd_down"
)
// keyNames define a map of key names to MMKeyCode
var keyNames = map[string]C.MMKeyCode{
"backspace": C.K_BACKSPACE,
"delete": C.K_DELETE,
"enter": C.K_RETURN,
"tab": C.K_TAB,
"esc": C.K_ESCAPE,
"escape": C.K_ESCAPE,
"up": C.K_UP,
"down": C.K_DOWN,
"right": C.K_RIGHT,
"left": C.K_LEFT,
"home": C.K_HOME,
"end": C.K_END,
"pageup": C.K_PAGEUP,
"pagedown": C.K_PAGEDOWN,
//
"f1": C.K_F1,
"f2": C.K_F2,
"f3": C.K_F3,
"f4": C.K_F4,
"f5": C.K_F5,
"f6": C.K_F6,
"f7": C.K_F7,
"f8": C.K_F8,
"f9": C.K_F9,
"f10": C.K_F10,
"f11": C.K_F11,
"f12": C.K_F12,
"f13": C.K_F13,
"f14": C.K_F14,
"f15": C.K_F15,
"f16": C.K_F16,
"f17": C.K_F17,
"f18": C.K_F18,
"f19": C.K_F19,
"f20": C.K_F20,
"f21": C.K_F21,
"f22": C.K_F22,
"f23": C.K_F23,
"f24": C.K_F24,
//
"cmd": C.K_META,
"lcmd": C.K_LMETA,
"rcmd": C.K_RMETA,
"command": C.K_META,
"alt": C.K_ALT,
"lalt": C.K_LALT,
"ralt": C.K_RALT,
"ctrl": C.K_CONTROL,
"lctrl": C.K_LCONTROL,
"rctrl": C.K_RCONTROL,
"control": C.K_CONTROL,
"shift": C.K_SHIFT,
"lshift": C.K_LSHIFT,
"rshift": C.K_RSHIFT,
"right_shift": C.K_RSHIFT,
"capslock": C.K_CAPSLOCK,
"space": C.K_SPACE,
"print": C.K_PRINTSCREEN,
"printscreen": C.K_PRINTSCREEN,
"insert": C.K_INSERT,
"menu": C.K_MENU,
"audio_mute": C.K_AUDIO_VOLUME_MUTE,
"audio_vol_down": C.K_AUDIO_VOLUME_DOWN,
"audio_vol_up": C.K_AUDIO_VOLUME_UP,
"audio_play": C.K_AUDIO_PLAY,
"audio_stop": C.K_AUDIO_STOP,
"audio_pause": C.K_AUDIO_PAUSE,
"audio_prev": C.K_AUDIO_PREV,
"audio_next": C.K_AUDIO_NEXT,
"audio_rewind": C.K_AUDIO_REWIND,
"audio_forward": C.K_AUDIO_FORWARD,
"audio_repeat": C.K_AUDIO_REPEAT,
"audio_random": C.K_AUDIO_RANDOM,
"num0": C.K_NUMPAD_0,
"num1": C.K_NUMPAD_1,
"num2": C.K_NUMPAD_2,
"num3": C.K_NUMPAD_3,
"num4": C.K_NUMPAD_4,
"num5": C.K_NUMPAD_5,
"num6": C.K_NUMPAD_6,
"num7": C.K_NUMPAD_7,
"num8": C.K_NUMPAD_8,
"num9": C.K_NUMPAD_9,
"num_lock": C.K_NUMPAD_LOCK,
// todo: removed
"numpad_0": C.K_NUMPAD_0,
"numpad_1": C.K_NUMPAD_1,
"numpad_2": C.K_NUMPAD_2,
"numpad_3": C.K_NUMPAD_3,
"numpad_4": C.K_NUMPAD_4,
"numpad_5": C.K_NUMPAD_5,
"numpad_6": C.K_NUMPAD_6,
"numpad_7": C.K_NUMPAD_7,
"numpad_8": C.K_NUMPAD_8,
"numpad_9": C.K_NUMPAD_9,
"numpad_lock": C.K_NUMPAD_LOCK,
"num.": C.K_NUMPAD_DECIMAL,
"num+": C.K_NUMPAD_PLUS,
"num-": C.K_NUMPAD_MINUS,
"num*": C.K_NUMPAD_MUL,
"num/": C.K_NUMPAD_DIV,
"num_clear": C.K_NUMPAD_CLEAR,
"num_enter": C.K_NUMPAD_ENTER,
"num_equal": C.K_NUMPAD_EQUAL,
"lights_mon_up": C.K_LIGHTS_MON_UP,
"lights_mon_down": C.K_LIGHTS_MON_DOWN,
"lights_kbd_toggle": C.K_LIGHTS_KBD_TOGGLE,
"lights_kbd_up": C.K_LIGHTS_KBD_UP,
"lights_kbd_down": C.K_LIGHTS_KBD_DOWN,
// { NULL: C.K_NOT_A_KEY }
}
// CmdCtrl If the operating system is macOS, return the key string "cmd",
// otherwise return the key string "ctrl
func CmdCtrl() string {
if runtime.GOOS == "darwin" {
return "cmd"
}
return "ctrl"
}
// It sends a key press and release to the active application
func tapKeyCode(code C.MMKeyCode, flags C.MMKeyFlags, pid C.uintptr) {
C.toggleKeyCode(code, true, flags, pid)
MilliSleep(3)
C.toggleKeyCode(code, false, flags, pid)
}
var keyErr = errors.New("Invalid key flag specified.")
func checkKeyCodes(k string) (key C.MMKeyCode, err error) {
if k == "" {
return
}
if len(k) == 1 {
val1 := C.CString(k)
defer C.free(unsafe.Pointer(val1))
key = C.keyCodeForChar(*val1)
if key == C.K_NOT_A_KEY {
err = keyErr
return
}
return
}
if v, ok := keyNames[k]; ok {
key = v
if key == C.K_NOT_A_KEY {
err = keyErr
return
}
}
return
}
func checkKeyFlags(f string) (flags C.MMKeyFlags) {
m := map[string]C.MMKeyFlags{
"alt": C.MOD_ALT,
"ralt": C.MOD_ALT,
"lalt": C.MOD_ALT,
"cmd":
gitextract_108ox7j1/ ├── .circleci/ │ ├── config.yml │ └── images/ │ └── primary/ │ └── Dockerfile ├── .github/ │ ├── CODEOWNERS │ ├── CONTRIBUTING.md │ ├── issue_template.md │ ├── pull_request_template.md │ └── workflows/ │ └── go.yml ├── .gitignore ├── .travis.yml ├── CLA.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── appveyor.yml ├── base/ │ ├── LICENSE │ ├── MMBitmap.h │ ├── base.go │ ├── bitmap_free_c.h │ ├── deadbeef_rand.h │ ├── deadbeef_rand_c.h │ ├── inline_keywords.h │ ├── microsleep.h │ ├── os.h │ ├── pubs.h │ ├── rgb.h │ ├── types.h │ └── xdisplay_c.h ├── clipboard/ │ ├── README.md │ ├── clipboard.go │ ├── clipboard_darwin.go │ ├── clipboard_test.go │ ├── clipboard_unix.go │ ├── clipboard_windows.go │ ├── cmd/ │ │ ├── gocopy/ │ │ │ └── gocopy.go │ │ └── gopaste/ │ │ └── gopaste.go │ └── example/ │ └── example.go ├── cv/ │ ├── README.md │ └── gocv.go ├── doc.go ├── docs/ │ ├── CHANGELOG.md │ ├── README.md │ ├── archive/ │ │ ├── README_zh.md │ │ ├── doc.md │ │ └── doc_zh.md │ ├── install.md │ └── keys.md ├── event/ │ ├── android/ │ │ └── event_c.h │ └── ios/ │ └── event_c.h ├── examples/ │ ├── README.md │ ├── key/ │ │ └── main.go │ ├── main.go │ ├── mouse/ │ │ └── main.go │ ├── scale/ │ │ └── main.go │ ├── screen/ │ │ └── main.go │ └── window/ │ └── main.go ├── go.mod ├── go.sum ├── img.go ├── key/ │ ├── key.go │ ├── key_windows.go │ ├── keycode.h │ ├── keycode_c.h │ ├── keypress.h │ └── keypress_c.h ├── key.go ├── keycode.go ├── mouse/ │ ├── mouse.go │ ├── mouse.h │ ├── mouse_c.h │ ├── mouse_darwin.go │ ├── mouse_windows.go │ └── mouse_x11.go ├── ps.go ├── robot_info_test.go ├── robotgo.go ├── robotgo_adb.go ├── robotgo_android.go ├── robotgo_fn_v1.go ├── robotgo_mac.go ├── robotgo_mac_unix.go ├── robotgo_mac_win.go ├── robotgo_ocr.go ├── robotgo_test.go ├── robotgo_win.go ├── robotgo_x11.go ├── screen/ │ ├── goScreen.h │ ├── screen.go │ ├── screen_c.h │ └── screengrab_c.h ├── screen.go ├── test/ │ └── index.html ├── wayland_n.go ├── window/ │ ├── alert_c.h │ ├── goWindow.h │ ├── pub.h │ ├── win_sys.h │ ├── window.go │ └── window.h └── windows_n.go
SYMBOL INDEX (598 symbols across 51 files)
FILE: base/MMBitmap.h
type _MMBitmap (line 10) | struct _MMBitmap {
type MMBitmap (line 20) | typedef struct _MMBitmap MMBitmap;
type MMBitmap (line 21) | typedef MMBitmap *MMBitmapRef;
FILE: base/bitmap_free_c.h
function MMBitmapRef (line 5) | MMBitmapRef createMMBitmap_c(uint8_t *buffer, int32_t width, int32_t hei...
function destroyMMBitmap (line 21) | void destroyMMBitmap(MMBitmapRef bitmap) {
function destroyMMBitmapBuffer (line 32) | void destroyMMBitmapBuffer(char * bitmapBuffer, void * hint) {
FILE: base/deadbeef_rand_c.h
function deadbeef_rand (line 7) | uint32_t deadbeef_rand(void) {
function deadbeef_srand (line 13) | void deadbeef_srand(uint32_t x) {
function deadbeef_generate_seed (line 19) | uint32_t deadbeef_generate_seed(void) {
FILE: base/microsleep.h
function H_INLINE (line 19) | H_INLINE void microsleep(double milliseconds) {
FILE: base/pubs.h
function BOOL (line 2) | BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT ...
type WNDINFO (line 8) | typedef struct{
function BOOL (line 13) | BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam){
function HWND (line 25) | HWND GetHwndByPid(DWORD dwProcessId) {
FILE: base/rgb.h
type _MMRGBColor (line 13) | struct _MMRGBColor {
type MMRGBColor (line 18) | typedef struct _MMRGBColor MMRGBColor;
type MMRGBHex (line 21) | typedef uint32_t MMRGBHex;
function H_INLINE (line 30) | H_INLINE MMRGBHex hexFromMMRGB(MMRGBColor rgb) {
function H_INLINE (line 39) | H_INLINE MMRGBColor MMRGBFromHex(MMRGBHex hex) {
function H_INLINE (line 53) | H_INLINE int MMRGBColorSimilarToColor(MMRGBColor c1, MMRGBColor c2, floa...
function H_INLINE (line 67) | H_INLINE int MMRGBHexSimilarToColor(MMRGBHex h1, MMRGBHex h2, float tole...
FILE: base/types.h
type intptr (line 13) | typedef int64_t intptr;
type uintptr (line 14) | typedef uint64_t uintptr;
type intptr (line 16) | typedef int32_t intptr;
type uintptr (line 17) | typedef uint32_t uintptr;
type _MMPointInt32 (line 20) | struct _MMPointInt32 {
type MMPointInt32 (line 24) | typedef struct _MMPointInt32 MMPointInt32;
type _MMSizeInt32 (line 26) | struct _MMSizeInt32 {
type MMSizeInt32 (line 30) | typedef struct _MMSizeInt32 MMSizeInt32;
type _MMRectInt32 (line 32) | struct _MMRectInt32 {
type MMRectInt32 (line 36) | typedef struct _MMRectInt32 MMRectInt32;
function H_INLINE (line 38) | H_INLINE MMPointInt32 MMPointInt32Make(int32_t x, int32_t y) {
function H_INLINE (line 45) | H_INLINE MMSizeInt32 MMSizeInt32Make(int32_t w, int32_t h) {
function H_INLINE (line 52) | H_INLINE MMRectInt32 MMRectInt32Make(int32_t x, int32_t y, int32_t w, in...
FILE: base/xdisplay_c.h
function XCloseMainDisplay (line 11) | void XCloseMainDisplay(void) {
function Display (line 18) | Display *XGetMainDisplay(void) {
function setXDisplay (line 50) | void setXDisplay(char *name) {
FILE: clipboard/clipboard.go
function ReadAll (line 13) | func ReadAll() (string, error) {
function WriteAll (line 18) | func WriteAll(text string) error {
FILE: clipboard/clipboard_darwin.go
function getPasteCommand (line 19) | func getPasteCommand() *exec.Cmd {
function getCopyCommand (line 23) | func getCopyCommand() *exec.Cmd {
function readAll (line 27) | func readAll() (string, error) {
function writeAll (line 36) | func writeAll(text string) error {
FILE: clipboard/clipboard_test.go
function TestCopyAndPaste (line 16) | func TestCopyAndPaste(t *testing.T) {
function TestMultiCopyAndPaste (line 34) | func TestMultiCopyAndPaste(t *testing.T) {
function BenchmarkReadAll (line 65) | func BenchmarkReadAll(b *testing.B) {
function BenchmarkWriteAll (line 71) | func BenchmarkWriteAll(b *testing.B) {
FILE: clipboard/clipboard_unix.go
constant xsel (line 16) | xsel = "xsel"
constant xclip (line 17) | xclip = "xclip"
function init (line 35) | func init() {
function getPasteCommand (line 53) | func getPasteCommand() *exec.Cmd {
function getCopyCommand (line 60) | func getCopyCommand() *exec.Cmd {
function readAll (line 67) | func readAll() (string, error) {
function writeAll (line 81) | func writeAll(text string) error {
FILE: clipboard/clipboard_windows.go
constant cfUnicodetext (line 17) | cfUnicodetext = 13
constant gmemMoveable (line 19) | gmemMoveable = 0x0002
function waitOpenClipboard (line 39) | func waitOpenClipboard() error {
function readAll (line 57) | func readAll() (string, error) {
function writeAll (line 85) | func writeAll(text string) error {
FILE: clipboard/cmd/gocopy/gocopy.go
function main (line 10) | func main() {
FILE: clipboard/cmd/gopaste/gopaste.go
function main (line 9) | func main() {
FILE: clipboard/example/example.go
function main (line 9) | func main() {
FILE: examples/key/main.go
function typeStr (line 21) | func typeStr() {
function keyTap (line 41) | func keyTap() {
function special (line 78) | func special() {
function keyToggle (line 86) | func keyToggle() {
function cilp (line 102) | func cilp() {
function key (line 119) | func key() {
function main (line 133) | func main() {
FILE: examples/main.go
function main (line 21) | func main() {
FILE: examples/mouse/main.go
function move (line 21) | func move() {
function click (line 45) | func click() {
function get (line 57) | func get() {
function toggleAndScroll (line 68) | func toggleAndScroll() {
function mouse (line 84) | func mouse() {
function main (line 98) | func main() {
FILE: examples/scale/main.go
function main (line 9) | func main() {
function old (line 33) | func old() {
FILE: examples/screen/main.go
function bitmap (line 22) | func bitmap() {
function color (line 59) | func color() {
function screen (line 83) | func screen() {
function main (line 103) | func main() {
FILE: examples/window/main.go
function alert (line 21) | func alert() {
function get (line 30) | func get() {
function findIds (line 50) | func findIds() {
function active (line 90) | func active() {
function findName (line 98) | func findName() {
function ps (line 117) | func ps() {
function window (line 139) | func window() {
function main (line 159) | func main() {
FILE: img.go
function DecodeImg (line 23) | func DecodeImg(path string) (image.Image, string, error) {
function OpenImg (line 28) | func OpenImg(path string) ([]byte, error) {
function Read (line 33) | func Read(path string) (image.Image, error) {
function Save (line 38) | func Save(img image.Image, path string, quality ...int) error {
function SaveImg (line 43) | func SaveImg(b []byte, path string) error {
function SavePng (line 48) | func SavePng(img image.Image, path string) error {
function SaveJpeg (line 53) | func SaveJpeg(img image.Image, path string, quality ...int) error {
function ToByteImg (line 58) | func ToByteImg(img image.Image, fm ...string) []byte {
function ToStringImg (line 63) | func ToStringImg(img image.Image, fm ...string) string {
function StrToImg (line 68) | func StrToImg(data string) (image.Image, error) {
function ByteToImg (line 73) | func ByteToImg(b []byte) (image.Image, error) {
function ImgSize (line 78) | func ImgSize(path string) (int, int, error) {
function Width (line 83) | func Width(img image.Image) int {
function Height (line 88) | func Height(img image.Image) int {
function RGBAToBitmap (line 93) | func RGBAToBitmap(r1 *image.RGBA) (bit Bitmap) {
function ImgToBitmap (line 108) | func ImgToBitmap(m image.Image) (bit Bitmap) {
function ToUint8p (line 124) | func ToUint8p(dst []uint8) *uint8 {
function ToRGBAGo (line 138) | func ToRGBAGo(bmp1 Bitmap) *image.RGBA {
function val (line 147) | func val(p *uint8, n int) uint8 {
function copyToVUint8A (line 154) | func copyToVUint8A(dst []uint8, src *uint8) {
function GetText (line 166) | func GetText(imgPath string, args ...string) (string, error) {
FILE: key.go
constant KeyA (line 36) | KeyA = "a"
constant KeyB (line 37) | KeyB = "b"
constant KeyC (line 38) | KeyC = "c"
constant KeyD (line 39) | KeyD = "d"
constant KeyE (line 40) | KeyE = "e"
constant KeyF (line 41) | KeyF = "f"
constant KeyG (line 42) | KeyG = "g"
constant KeyH (line 43) | KeyH = "h"
constant KeyI (line 44) | KeyI = "i"
constant KeyJ (line 45) | KeyJ = "j"
constant KeyK (line 46) | KeyK = "k"
constant KeyL (line 47) | KeyL = "l"
constant KeyM (line 48) | KeyM = "m"
constant KeyN (line 49) | KeyN = "n"
constant KeyO (line 50) | KeyO = "o"
constant KeyP (line 51) | KeyP = "p"
constant KeyQ (line 52) | KeyQ = "q"
constant KeyR (line 53) | KeyR = "r"
constant KeyS (line 54) | KeyS = "s"
constant KeyT (line 55) | KeyT = "t"
constant KeyU (line 56) | KeyU = "u"
constant KeyV (line 57) | KeyV = "v"
constant KeyW (line 58) | KeyW = "w"
constant KeyX (line 59) | KeyX = "x"
constant KeyY (line 60) | KeyY = "y"
constant KeyZ (line 61) | KeyZ = "z"
constant CapA (line 63) | CapA = "A"
constant CapB (line 64) | CapB = "B"
constant CapC (line 65) | CapC = "C"
constant CapD (line 66) | CapD = "D"
constant CapE (line 67) | CapE = "E"
constant CapF (line 68) | CapF = "F"
constant CapG (line 69) | CapG = "G"
constant CapH (line 70) | CapH = "H"
constant CapI (line 71) | CapI = "I"
constant CapJ (line 72) | CapJ = "J"
constant CapK (line 73) | CapK = "K"
constant CapL (line 74) | CapL = "L"
constant CapM (line 75) | CapM = "M"
constant CapN (line 76) | CapN = "N"
constant CapO (line 77) | CapO = "O"
constant CapP (line 78) | CapP = "P"
constant CapQ (line 79) | CapQ = "Q"
constant CapR (line 80) | CapR = "R"
constant CapS (line 81) | CapS = "S"
constant CapT (line 82) | CapT = "T"
constant CapU (line 83) | CapU = "U"
constant CapV (line 84) | CapV = "V"
constant CapW (line 85) | CapW = "W"
constant CapX (line 86) | CapX = "X"
constant CapY (line 87) | CapY = "Y"
constant CapZ (line 88) | CapZ = "Z"
constant Key0 (line 90) | Key0 = "0"
constant Key1 (line 91) | Key1 = "1"
constant Key2 (line 92) | Key2 = "2"
constant Key3 (line 93) | Key3 = "3"
constant Key4 (line 94) | Key4 = "4"
constant Key5 (line 95) | Key5 = "5"
constant Key6 (line 96) | Key6 = "6"
constant Key7 (line 97) | Key7 = "7"
constant Key8 (line 98) | Key8 = "8"
constant Key9 (line 99) | Key9 = "9"
constant KeyGrave (line 100) | KeyGrave = "`"
constant KeyQuoter (line 101) | KeyQuoter = '"'
constant KeyQuote (line 102) | KeyQuote = "'"
constant Backspace (line 105) | Backspace = "backspace"
constant Delete (line 106) | Delete = "delete"
constant Enter (line 107) | Enter = "enter"
constant Tab (line 108) | Tab = "tab"
constant Esc (line 109) | Esc = "esc"
constant Escape (line 110) | Escape = "escape"
constant Up (line 111) | Up = "up"
constant Down (line 112) | Down = "down"
constant Right (line 113) | Right = "right"
constant Left (line 114) | Left = "left"
constant Home (line 115) | Home = "home"
constant End (line 116) | End = "end"
constant Pageup (line 117) | Pageup = "pageup"
constant Pagedown (line 118) | Pagedown = "pagedown"
constant F1 (line 120) | F1 = "f1"
constant F2 (line 121) | F2 = "f2"
constant F3 (line 122) | F3 = "f3"
constant F4 (line 123) | F4 = "f4"
constant F5 (line 124) | F5 = "f5"
constant F6 (line 125) | F6 = "f6"
constant F7 (line 126) | F7 = "f7"
constant F8 (line 127) | F8 = "f8"
constant F9 (line 128) | F9 = "f9"
constant F10 (line 129) | F10 = "f10"
constant F11 (line 130) | F11 = "f11"
constant F12 (line 131) | F12 = "f12"
constant F13 (line 132) | F13 = "f13"
constant F14 (line 133) | F14 = "f14"
constant F15 (line 134) | F15 = "f15"
constant F16 (line 135) | F16 = "f16"
constant F17 (line 136) | F17 = "f17"
constant F18 (line 137) | F18 = "f18"
constant F19 (line 138) | F19 = "f19"
constant F20 (line 139) | F20 = "f20"
constant F21 (line 140) | F21 = "f21"
constant F22 (line 141) | F22 = "f22"
constant F23 (line 142) | F23 = "f23"
constant F24 (line 143) | F24 = "f24"
constant Cmd (line 145) | Cmd = "cmd"
constant Lcmd (line 146) | Lcmd = "lcmd"
constant Rcmd (line 147) | Rcmd = "rcmd"
constant Alt (line 149) | Alt = "alt"
constant Lalt (line 150) | Lalt = "lalt"
constant Ralt (line 151) | Ralt = "ralt"
constant Ctrl (line 152) | Ctrl = "ctrl"
constant Lctrl (line 153) | Lctrl = "lctrl"
constant Rctrl (line 154) | Rctrl = "rctrl"
constant Control (line 155) | Control = "control"
constant Shift (line 156) | Shift = "shift"
constant Lshift (line 157) | Lshift = "lshift"
constant Rshift (line 158) | Rshift = "rshift"
constant Capslock (line 160) | Capslock = "capslock"
constant Space (line 161) | Space = "space"
constant Print (line 162) | Print = "print"
constant Printscreen (line 163) | Printscreen = "printscreen"
constant Insert (line 164) | Insert = "insert"
constant Menu (line 165) | Menu = "menu"
constant AudioMute (line 167) | AudioMute = "audio_mute"
constant AudioVolDown (line 168) | AudioVolDown = "audio_vol_down"
constant AudioVolUp (line 169) | AudioVolUp = "audio_vol_up"
constant AudioPlay (line 170) | AudioPlay = "audio_play"
constant AudioStop (line 171) | AudioStop = "audio_stop"
constant AudioPause (line 172) | AudioPause = "audio_pause"
constant AudioPrev (line 173) | AudioPrev = "audio_prev"
constant AudioNext (line 174) | AudioNext = "audio_next"
constant AudioRewind (line 175) | AudioRewind = "audio_rewind"
constant AudioForward (line 176) | AudioForward = "audio_forward"
constant AudioRepeat (line 177) | AudioRepeat = "audio_repeat"
constant AudioRandom (line 178) | AudioRandom = "audio_random"
constant Num0 (line 180) | Num0 = "num0"
constant Num1 (line 181) | Num1 = "num1"
constant Num2 (line 182) | Num2 = "num2"
constant Num3 (line 183) | Num3 = "num3"
constant Num4 (line 184) | Num4 = "num4"
constant Num5 (line 185) | Num5 = "num5"
constant Num6 (line 186) | Num6 = "num6"
constant Num7 (line 187) | Num7 = "num7"
constant Num8 (line 188) | Num8 = "num8"
constant Num9 (line 189) | Num9 = "num9"
constant NumLock (line 190) | NumLock = "num_lock"
constant NumDecimal (line 192) | NumDecimal = "num."
constant NumPlus (line 193) | NumPlus = "num+"
constant NumMinus (line 194) | NumMinus = "num-"
constant NumMul (line 195) | NumMul = "num*"
constant NumDiv (line 196) | NumDiv = "num/"
constant NumClear (line 197) | NumClear = "num_clear"
constant NumEnter (line 198) | NumEnter = "num_enter"
constant NumEqual (line 199) | NumEqual = "num_equal"
constant LightsMonUp (line 201) | LightsMonUp = "lights_mon_up"
constant LightsMonDown (line 202) | LightsMonDown = "lights_mon_down"
constant LightsKbdToggle (line 203) | LightsKbdToggle = "lights_kbd_toggle"
constant LightsKbdUp (line 204) | LightsKbdUp = "lights_kbd_up"
constant LightsKbdDown (line 205) | LightsKbdDown = "lights_kbd_down"
function CmdCtrl (line 330) | func CmdCtrl() string {
function tapKeyCode (line 338) | func tapKeyCode(code C.MMKeyCode, flags C.MMKeyFlags, pid C.uintptr) {
function checkKeyCodes (line 346) | func checkKeyCodes(k string) (key C.MMKeyCode, err error) {
function checkKeyFlags (line 373) | func checkKeyFlags(f string) (flags C.MMKeyFlags) {
function getFlagsFromValue (line 396) | func getFlagsFromValue(value []string) (flags C.MMKeyFlags) {
function upKeyArr (line 411) | func upKeyArr(keyArr []string, pid int) {
function keyTaps (line 418) | func keyTaps(k string, keyArr []string, pid int) error {
function getKeyDown (line 431) | func getKeyDown(keyArr []string) (bool, []string) {
function keyTogglesB (line 447) | func keyTogglesB(k string, down bool, keyArr []string, pid int) error {
function keyToggles (line 462) | func keyToggles(k string, keyArr []string, pid int) error {
function ToInterfaces (line 478) | func ToInterfaces(fields []string) []interface{} {
function ToStrings (line 487) | func ToStrings(fields []interface{}) []string {
function toErr (line 496) | func toErr(str *C.char) error {
function appendShift (line 504) | func appendShift(key string, len1 int, args ...interface{}) (string, []i...
function KeyTap (line 536) | func KeyTap(key string, args ...interface{}) error {
function getToggleArgs (line 557) | func getToggleArgs(args ...interface{}) (pid int, keyArr []string) {
function KeyToggle (line 580) | func KeyToggle(key string, args ...interface{}) error {
function KeyPress (line 587) | func KeyPress(key string, args ...interface{}) error {
function KeyDown (line 598) | func KeyDown(key string, args ...interface{}) error {
function KeyUp (line 603) | func KeyUp(key string, args ...interface{}) error {
function ReadAll (line 610) | func ReadAll() (string, error) {
function WriteAll (line 615) | func WriteAll(text string) error {
function CharCodeAt (line 620) | func CharCodeAt(s string, n int) rune {
function UnicodeType (line 633) | func UnicodeType(str uint32, args ...int) {
function ToUC (line 649) | func ToUC(text string) []string {
function inputUTF (line 669) | func inputUTF(str string) {
function TypeStr (line 679) | func TypeStr(str string, args ...int) {
function Type (line 691) | func Type(str string, args ...int) {
function PasteStr (line 735) | func PasteStr(str string) error {
function Paste (line 741) | func Paste(str string) error {
function CmdV (line 750) | func CmdV() error {
function TypeStrDelay (line 761) | func TypeStrDelay(str string, delay int) {
function TypeDelay (line 767) | func TypeDelay(str string, delay int) {
function SetDelay (line 774) | func SetDelay(d ...int) {
FILE: key/keycode.h
type _MMKeyCode (line 13) | enum _MMKeyCode {
type CGKeyCode (line 122) | typedef CGKeyCode MMKeyCode;
type _MMKeyCode (line 129) | enum _MMKeyCode {
type KeySym (line 237) | typedef KeySym MMKeyCode;
type XSpecialCharacterMapping (line 243) | struct XSpecialCharacterMapping {
type XSpecialCharacterMapping (line 248) | struct XSpecialCharacterMapping
type _MMKeyCode (line 288) | enum _MMKeyCode {
type MMKeyCode (line 395) | typedef int MMKeyCode;
FILE: key/keycode_c.h
function MMKeyCode (line 13) | MMKeyCode keyCodeForChar(const char c) {
function CFStringRef (line 96) | CFStringRef createStringForKey(CGKeyCode keyCode){
FILE: key/keypress.h
type MMKeyFlags (line 13) | typedef enum {
type _MMKeyFlags (line 21) | enum _MMKeyFlags {
type MMKeyFlags (line 28) | typedef unsigned int MMKeyFlags;
type _MMKeyFlags (line 30) | enum _MMKeyFlags {
type MMKeyFlags (line 38) | typedef unsigned int MMKeyFlags;
FILE: key/keypress_c.h
function HWND (line 31) | HWND getHwnd(uintptr pid, int8_t isPid) {
function WIN32_KEY_EVENT_WAIT (line 39) | void WIN32_KEY_EVENT_WAIT(MMKeyCode key, DWORD flags, uintptr pid) {
function X_KEY_EVENT (line 46) | void X_KEY_EVENT(Display *display, MMKeyCode key, bool is_press) {
function X_KEY_EVENT_WAIT (line 51) | void X_KEY_EVENT_WAIT(Display *display, MMKeyCode key, bool is_press) {
function SendTo (line 58) | int SendTo(uintptr pid, CGEventRef event) {
function io_connect_t (line 69) | static io_connect_t _getAuxiliaryKeyDriver(void) {
function win32KeyEvent (line 93) | void win32KeyEvent(int key, MMKeyFlags flags, uintptr pid, int8_t isPid) {
function toggleKeyCode (line 164) | void toggleKeyCode(MMKeyCode code, const bool down, MMKeyFlags flags, ui...
function toUpper (line 226) | bool toUpper(char c) {
function toggleKey (line 242) | void toggleKey(char c, const bool down, MMKeyFlags flags, uintptr pid) {
function toggleUnicode (line 274) | void toggleUnicode(UniChar ch, const bool down, uintptr pid) {
function unicodeType (line 296) | void unicodeType(const unsigned value, uintptr pid, int8_t isPid) {
function input_utf (line 334) | int input_utf(const char *utf) {
function input_utf (line 357) | int input_utf(const char *utf){
FILE: keycode.go
type uMap (line 18) | type uMap
constant Mleft (line 25) | Mleft = "left"
constant Mright (line 26) | Mright = "right"
constant Center (line 27) | Center = "center"
constant WheelDown (line 28) | WheelDown = "wheelDown"
constant WheelUp (line 29) | WheelUp = "wheelUp"
constant WheelLeft (line 30) | WheelLeft = "wheelLeft"
constant WheelRight (line 31) | WheelRight = "wheelRight"
FILE: mouse/mouse.h
type MMMouseButton (line 12) | typedef enum {
type _MMMouseButton (line 22) | enum _MMMouseButton {
type MMMouseButton (line 31) | typedef unsigned int MMMouseButton;
type _MMMouseButton (line 33) | enum _MMMouseButton {
type MMMouseButton (line 42) | typedef unsigned int MMMouseButton;
FILE: mouse/mouse_c.h
function CGEventType (line 29) | CGEventType MMMouseDownToCGEventType(MMMouseButton button) {
function CGEventType (line 39) | CGEventType MMMouseUpToCGEventType(MMMouseButton button) {
function CGEventType (line 45) | CGEventType MMMouseDragToCGEventType(MMMouseButton button) {
function CGEventType (line 51) | CGEventType MMMouseToCGEventType(bool down, MMMouseButton button) {
function DWORD (line 57) | DWORD MMMouseUpToMEventF(MMMouseButton button) {
function DWORD (line 63) | DWORD MMMouseDownToMEventF(MMMouseButton button) {
function DWORD (line 69) | DWORD MMMouseToMEventF(bool down, MMMouseButton button) {
function calculateDeltas (line 77) | void calculateDeltas(CGEventRef *event, MMPointInt32 point) {
function moveMouse (line 94) | void moveMouse(MMPointInt32 point){
function dragMouse (line 114) | void dragMouse(MMPointInt32 point, const MMMouseButton button){
function MMPointInt32 (line 131) | MMPointInt32 location() {
function toggleMouse (line 157) | int toggleMouse(bool down, MMMouseButton button) {
function clickMouse (line 193) | int clickMouse(MMMouseButton button){
function doubleClick (line 204) | int doubleClick(MMMouseButton button, int count){
function scrollMouseXY (line 240) | void scrollMouseXY(int x, int y) {
function crude_hypot (line 300) | static double crude_hypot(double x, double y){
function smoothlyMoveMouseImpl (line 313) | static bool smoothlyMoveMouseImpl(MMPointInt32 endPoint, double lowSpeed...
function smoothlyMoveMouse (line 352) | bool smoothlyMoveMouse(MMPointInt32 endPoint, double lowSpeed, double hi...
function smoothlyDragMouse (line 356) | bool smoothlyDragMouse(MMPointInt32 endPoint, double lowSpeed, double hi...
FILE: ps.go
type Nps (line 17) | type Nps struct
function Pids (line 23) | func Pids() ([]int, error) {
function PidExists (line 28) | func PidExists(pid int) (bool, error) {
function Process (line 33) | func Process() ([]Nps, error) {
function FindName (line 49) | func FindName(pid int) (string, error) {
function FindNames (line 54) | func FindNames() ([]string, error) {
function FindIds (line 61) | func FindIds(name string) ([]int, error) {
function FindPath (line 66) | func FindPath(pid int) (string, error) {
function Run (line 71) | func Run(path string) ([]byte, error) {
function Kill (line 76) | func Kill(pid int) error {
FILE: robot_info_test.go
function TestGetVer (line 24) | func TestGetVer(t *testing.T) {
function TestGetScreenSize (line 31) | func TestGetScreenSize(t *testing.T) {
function TestGetSysScale (line 42) | func TestGetSysScale(t *testing.T) {
function TestGetTitle (line 50) | func TestGetTitle(t *testing.T) {
FILE: robotgo.go
constant Version (line 67) | Version = "v1.00.0.1189, MT. Baker!"
function GetVersion (line 71) | func GetVersion() string {
type Map (line 92) | type Map
type CHex (line 94) | type CHex
type CBitmap (line 96) | type CBitmap
type Handle (line 98) | type Handle
type Bitmap (line 106) | type Bitmap struct
type Point (line 116) | type Point struct
type Size (line 122) | type Size struct
type Rect (line 127) | type Rect struct
function Try (line 133) | func Try(fun func(), handler func(interface{})) {
function MilliSleep (line 143) | func MilliSleep(tm int) {
function Sleep (line 148) | func Sleep(tm int) {
function MicroSleep (line 155) | func MicroSleep(tm float64) {
function GoString (line 160) | func GoString(char *C.char) string {
function ToMMRGBHex (line 174) | func ToMMRGBHex(hex CHex) C.MMRGBHex {
function UintToHex (line 179) | func UintToHex(u uint32) CHex {
function U32ToHex (line 185) | func U32ToHex(hex C.uint32_t) C.MMRGBHex {
function U8ToHex (line 190) | func U8ToHex(hex *C.uint8_t) C.MMRGBHex {
function PadHex (line 195) | func PadHex(hex C.MMRGBHex) string {
function PadHexs (line 204) | func PadHexs(hex CHex) string {
function HexToRgb (line 209) | func HexToRgb(hex uint32) *C.uint8_t {
function RgbToHex (line 214) | func RgbToHex(r, g, b uint8) C.uint32_t {
function GetPxColor (line 219) | func GetPxColor(x, y int, displayId ...int) C.MMRGBHex {
function GetPixelColor (line 229) | func GetPixelColor(x, y int, displayId ...int) string {
function GetLocationColor (line 234) | func GetLocationColor(displayId ...int) string {
function IsMain (line 240) | func IsMain(displayId int) bool {
function displayIdx (line 244) | func displayIdx(id ...int) int {
function getNumDisplays (line 256) | func getNumDisplays() int {
function GetHWNDByPid (line 261) | func GetHWNDByPid(pid int) int {
function SysScale (line 266) | func SysScale(displayId ...int) float64 {
function Scaled (line 273) | func Scaled(x int, displayId ...int) int {
function Scaled0 (line 279) | func Scaled0(x int, f float64) int {
function Scaled1 (line 284) | func Scaled1(x int, f float64) int {
function GetScreenSize (line 289) | func GetScreenSize() (int, int) {
function GetScreenRect (line 295) | func GetScreenRect(displayId ...int) Rect {
function GetScaleSize (line 317) | func GetScaleSize(displayId ...int) (int, int) {
function CaptureScreen (line 327) | func CaptureScreen(args ...int) CBitmap {
function CaptureGo (line 365) | func CaptureGo(args ...int) Bitmap {
function CaptureImg (line 373) | func CaptureImg(args ...int) (image.Image, error) {
function FreeBitmap (line 384) | func FreeBitmap(bitmap CBitmap) {
function FreeBitmapArr (line 390) | func FreeBitmapArr(bit ...CBitmap) {
function ToMMBitmapRef (line 397) | func ToMMBitmapRef(bit CBitmap) C.MMBitmapRef {
function ToBitmap (line 402) | func ToBitmap(bit CBitmap) Bitmap {
function ToCBitmap (line 416) | func ToCBitmap(bit Bitmap) CBitmap {
function ToImage (line 430) | func ToImage(bit CBitmap) image.Image {
function ToRGBA (line 435) | func ToRGBA(bit CBitmap) *image.RGBA {
function ImgToCBitmap (line 441) | func ImgToCBitmap(img image.Image) CBitmap {
function ByteToCBitmap (line 446) | func ByteToCBitmap(by []byte) CBitmap {
function SetXDisplayName (line 452) | func SetXDisplayName(name string) error {
function GetXDisplayName (line 461) | func GetXDisplayName() string {
function CloseMainDisplay (line 470) | func CloseMainDisplay() {
function ScaleX (line 477) | func ScaleX() int {
function CheckMouse (line 492) | func CheckMouse(btn string) C.MMMouseButton {
function MouseButtonString (line 511) | func MouseButtonString(btn C.MMMouseButton) string {
function MoveScale (line 529) | func MoveScale(x, y int, displayId ...int) (int, int) {
function Move (line 544) | func Move(x, y int, displayId ...int) {
function Drag (line 558) | func Drag(x, y int, args ...string) {
function DragSmooth (line 578) | func DragSmooth(x, y int, args ...interface{}) {
function smoothMove (line 585) | func smoothMove(x, y int, drag bool, args ...interface{}) bool {
function MoveSmooth (line 629) | func MoveSmooth(x, y int, args ...interface{}) bool {
function MoveArgs (line 634) | func MoveArgs(x, y int) (int, int) {
function MoveRelative (line 643) | func MoveRelative(x, y int) {
function MoveSmoothRelative (line 648) | func MoveSmoothRelative(x, y int, args ...interface{}) {
function Location (line 654) | func Location() (int, int) {
function ClickV1 (line 676) | func ClickV1(args ...interface{}) {
function Click (line 707) | func Click(args ...interface{}) error {
function MultiClick (line 751) | func MultiClick(button string, count int, click ...bool) error {
function formatClickError (line 771) | func formatClickError(code int, button C.MMMouseButton, stage string, co...
function MoveClick (line 820) | func MoveClick(x, y int, args ...interface{}) {
function MovesClick (line 829) | func MovesClick(x, y int, args ...interface{}) {
function Toggle (line 844) | func Toggle(key ...interface{}) error {
function MouseDown (line 863) | func MouseDown(key ...interface{}) error {
function MouseUp (line 868) | func MouseUp(key ...interface{}) error {
function Scroll (line 882) | func Scroll(x, y int, args ...int) {
function ScrollDir (line 902) | func ScrollDir(x int, direction ...interface{}) {
function ScrollSmooth (line 933) | func ScrollSmooth(to int, args ...int) {
function ScrollRelative (line 964) | func ScrollRelative(x, y int, args ...int) {
function alertArgs (line 979) | func alertArgs(args ...string) (string, string) {
function showAlert (line 996) | func showAlert(title, msg string, args ...string) bool {
function IsValid (line 1016) | func IsValid() bool {
function SetActive (line 1023) | func SetActive(win Handle) {
function SetActiveC (line 1028) | func SetActiveC(win C.MData) {
function GetActive (line 1033) | func GetActive() Handle {
function GetActiveC (line 1038) | func GetActiveC() C.MData {
function MinWindow (line 1045) | func MinWindow(pid int, args ...interface{}) {
function MaxWindow (line 1062) | func MaxWindow(pid int, args ...interface{}) {
function CloseWindow (line 1079) | func CloseWindow(args ...int) {
function SetHandle (line 1097) | func SetHandle(hwnd int) {
function SetHandlePid (line 1103) | func SetHandlePid(pid int, args ...int) {
function GetHandById (line 1113) | func GetHandById(id int, args ...int) Handle {
function GetHandByPid (line 1122) | func GetHandByPid(pid int, args ...int) Handle {
function GetHandPid (line 1129) | func GetHandPid(pid int, args ...int) Handle {
function GetHandByPidC (line 1134) | func GetHandByPidC(pid int, args ...int) C.MData {
function GetHandle (line 1144) | func GetHandle() int {
function GetBHandle (line 1156) | func GetBHandle() int {
function cgetTitle (line 1164) | func cgetTitle(pid, isPid int) string {
function GetTitle (line 1179) | func GetTitle(args ...int) string {
function GetPid (line 1194) | func GetPid() int {
function internalGetBounds (line 1200) | func internalGetBounds(pid, isPid int) (int, int, int, int) {
function internalGetClient (line 1206) | func internalGetClient(pid, isPid int) (int, int, int, int) {
function Is64Bit (line 1212) | func Is64Bit() bool {
function internalActive (line 1217) | func internalActive(pid, isPid int) {
function ActiveName (line 1237) | func ActiveName(name string) error {
FILE: robotgo_fn_v1.go
function MoveMouse (line 19) | func MoveMouse(x, y int) {
function DragMouse (line 27) | func DragMouse(x, y int, args ...interface{}) {
function MoveMouseSmooth (line 35) | func MoveMouseSmooth(x, y int, args ...interface{}) bool {
function GetMousePos (line 42) | func GetMousePos() (int, int) {
function MouseClick (line 51) | func MouseClick(args ...interface{}) {
function TypeStringDelayed (line 60) | func TypeStringDelayed(str string, delay int) {
function Scale1 (line 68) | func Scale1() int {
function Scale0 (line 92) | func Scale0() int {
function Mul (line 99) | func Mul(x int) int {
FILE: robotgo_mac.go
function GetMainId (line 23) | func GetMainId() int {
FILE: robotgo_mac_unix.go
function ScaleF (line 18) | func ScaleF(displayId ...int) float64 {
FILE: robotgo_mac_win.go
function GetBounds (line 18) | func GetBounds(pid int, args ...int) (int, int, int, int) {
function GetClient (line 28) | func GetClient(pid int, args ...int) (int, int, int, int) {
function internalGetTitle (line 38) | func internalGetTitle(pid int, args ...int) string {
function ActivePid (line 56) | func ActivePid(pid int, args ...int) error {
function DisplaysNum (line 67) | func DisplaysNum() int {
function Alert (line 78) | func Alert(title, msg string, args ...string) bool {
FILE: robotgo_ocr.go
function GetText (line 22) | func GetText(imgPath string, args ...string) (string, error) {
FILE: robotgo_test.go
function TestColor (line 23) | func TestColor(t *testing.T) {
function TestSize (line 33) | func TestSize(t *testing.T) {
function TestMoveMouse (line 43) | func TestMoveMouse(t *testing.T) {
function TestMoveMouseSmooth (line 52) | func TestMoveMouseSmooth(t *testing.T) {
function TestDragMouse (line 62) | func TestDragMouse(t *testing.T) {
function TestScrollMouse (line 71) | func TestScrollMouse(t *testing.T) {
function TestMoveRelative (line 82) | func TestMoveRelative(t *testing.T) {
function TestMoveSmoothRelative (line 94) | func TestMoveSmoothRelative(t *testing.T) {
function TestMouseToggle (line 106) | func TestMouseToggle(t *testing.T) {
function TestKey (line 120) | func TestKey(t *testing.T) {
function TestClip (line 139) | func TestClip(t *testing.T) {
function TestTypeStr (line 148) | func TestTypeStr(t *testing.T) {
function TestKeyCode (line 160) | func TestKeyCode(t *testing.T) {
function TestImage (line 174) | func TestImage(t *testing.T) {
function TestPs (line 196) | func TestPs(t *testing.T) {
FILE: robotgo_win.go
function FindWindow (line 26) | func FindWindow(name string) win.HWND {
function GetHWND (line 33) | func GetHWND() win.HWND {
function SendInput (line 39) | func SendInput(nInputs uint32, pInputs unsafe.Pointer, cbSize int32) uin...
function SendMsg (line 44) | func SendMsg(hwnd win.HWND, msg uint32, wParam, lParam uintptr) uintptr {
function SetActiveWindow (line 49) | func SetActiveWindow(hwnd win.HWND) win.HWND {
function SetFocus (line 54) | func SetFocus(hwnd win.HWND) win.HWND {
function SetForeg (line 59) | func SetForeg(hwnd win.HWND) bool {
function GetMain (line 64) | func GetMain() win.HWND {
function GetMainId (line 69) | func GetMainId() int {
function ScaleF (line 75) | func ScaleF(displayId ...int) (f float64) {
function GetDesktopWindow (line 96) | func GetDesktopWindow() win.HWND {
function GetMainDPI (line 101) | func GetMainDPI() int {
function GetDPI (line 106) | func GetDPI(hwnd win.HWND) uint32 {
function GetSysDPI (line 111) | func GetSysDPI(idx int32, dpi uint32) int32 {
FILE: robotgo_x11.go
function GetBounds (line 31) | func GetBounds(pid int, args ...int) (int, int, int, int) {
function GetClient (line 48) | func GetClient(pid int, args ...int) (int, int, int, int) {
function internalGetTitle (line 65) | func internalGetTitle(pid int, args ...int) string {
function ActivePidC (line 83) | func ActivePidC(pid int, args ...int) error {
function ActivePid (line 105) | func ActivePid(pid int, args ...int) error {
function GetXid (line 138) | func GetXid(xu *xgbutil.XUtil, pid int) (xproto.Window, error) {
function GetXidFromPid (line 155) | func GetXidFromPid(xu *xgbutil.XUtil, pid int) (xproto.Window, error) {
function GetXidByPid (line 160) | func GetXidByPid(xu *xgbutil.XUtil, pid int) (xproto.Window, error) {
function DisplaysNum (line 181) | func DisplaysNum() int {
function GetMainId (line 202) | func GetMainId() int {
function Alert (line 227) | func Alert(title, msg string, args ...string) bool {
FILE: screen.go
function GetDisplayBounds (line 22) | func GetDisplayBounds(i int) (x, y, w, h int) {
function GetDisplayRect (line 28) | func GetDisplayRect(i int) Rect {
function Capture (line 36) | func Capture(args ...int) (*image.RGBA, error) {
function SaveCapture (line 57) | func SaveCapture(path string, args ...int) error {
FILE: screen/goScreen.h
function padHex (line 18) | void padHex(MMRGBHex color, char* hex) {
function color_rgb_to_hex (line 42) | uint32_t color_rgb_to_hex(uint8_t r, uint8_t g, uint8_t b) {
function MMRGBHex (line 46) | MMRGBHex get_px_color(int32_t x, int32_t y, int32_t display_id) {
function close_main_display (line 82) | void close_main_display() {
function get_num_displays (line 90) | uint32_t get_num_displays() {
function uintptr (line 108) | uintptr get_hwnd_by_pid(uintptr pid) {
function bitmap_dealloc (line 117) | void bitmap_dealloc(MMBitmapRef bitmap) {
function MMBitmapRef (line 125) | MMBitmapRef capture_screen(int32_t x, int32_t y, int32_t w, int32_t h, i...
FILE: screen/screen_c.h
function sys_scale (line 13) | double sys_scale(int32_t display_id) {
function intptr (line 57) | intptr scaleX(){
function MMSizeInt32 (line 71) | MMSizeInt32 getMainDisplaySize(void) {
function MMRectInt32 (line 92) | MMRectInt32 getScreenRect(int32_t display_id) {
function pointVisibleOnMainDisplay (line 131) | bool pointVisibleOnMainDisplay(MMPointInt32 point){
FILE: screen/screengrab_c.h
function CGImageRef (line 19) | static CGImageRef capture15(CGDirectDisplayID id, CGRect diIntersectDisp...
function MMBitmapRef (line 67) | MMBitmapRef copyMMBitmapFromDisplayInRect(MMRectInt32 rect, int32_t disp...
FILE: window/alert_c.h
function CFStringRef (line 7) | CFStringRef CFStringCreateWithUTF8String(const char *title) {
function showAlert (line 13) | int showAlert(const char *title, const char *msg,
FILE: window/goWindow.h
function min_window (line 16) | void min_window(uintptr pid, bool state, int8_t isPid){
function max_window (line 32) | void max_window(uintptr pid, bool state, int8_t isPid){
function uintptr (line 45) | uintptr get_handle(){
function uintptr (line 57) | uintptr b_get_handle() {
function active_PID (line 67) | void active_PID(uintptr pid, int8_t isPid){
FILE: window/pub.h
type _MData (line 19) | struct _MData{
type MData (line 31) | typedef struct _MData MData;
type _Bounds (line 34) | struct _Bounds {
type Bounds (line 40) | typedef struct _Bounds Bounds;
function AXUIElementRef (line 47) | static AXUIElementRef GetUIElement(CGWindowID win){
function XHandleError (line 114) | static int XHandleError(Display* dp, XErrorEvent* e) { return 0; }
function XDismissErrors (line 116) | void XDismissErrors (void) {
type Hints (line 129) | struct Hints{
function LoadAtoms (line 155) | static void LoadAtoms (void){
function SetDesktopForWindow (line 216) | static void SetDesktopForWindow(MData win){
function Bounds (line 249) | static Bounds GetFrame(MData win){
function win_min (line 274) | void win_min(HWND hwnd, bool state){
function win_max (line 282) | void win_max(HWND hwnd, bool state){
FILE: window/win_sys.h
function Bounds (line 18) | Bounds get_bounds(uintptr pid, int8_t isPid){
function Bounds (line 99) | Bounds get_client(uintptr pid, int8_t isPid) {
FILE: window/window.h
function initWindow (line 26) | void initWindow(uintptr handle){
function Is64Bit (line 46) | bool Is64Bit() {
function MData (line 54) | MData set_handle_pid(uintptr pid, int8_t isPid){
function set_handle_pid_mData (line 69) | void set_handle_pid_mData(uintptr pid, int8_t isPid){
function is_valid (line 74) | bool is_valid() {
function IsAxEnabled (line 128) | bool IsAxEnabled(bool options){
function setHandle (line 176) | bool setHandle(uintptr handle){
function IsTopMost (line 231) | bool IsTopMost(void){
function IsMinimized (line 245) | bool IsMinimized(void){
function IsMaximized (line 270) | bool IsMaximized(void){
function set_active (line 284) | void set_active(const MData win) {
function MData (line 351) | MData get_active(void) {
function SetTopMost (line 446) | void SetTopMost(bool state){
function close_main_window (line 461) | void close_main_window () {
function close_window_by_PId (line 468) | void close_window_by_PId(uintptr pid, int8_t isPid){
function close_window_by_Id (line 474) | void close_window_by_Id(MData m_data){
function get_PID (line 586) | int32_t get_PID(void) {
Condensed preview — 99 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (335K chars).
[
{
"path": ".circleci/config.yml",
"chars": 882,
"preview": "version: 2\n\njobs:\n build:\n docker:\n # using custom image, see .circleci/images/primary/Dockerfile\n # - ima"
},
{
"path": ".circleci/images/primary/Dockerfile",
"chars": 552,
"preview": "# FROM golang:1.10.1\nFROM golang:1.24.2-stretch AS build\n# FROM govgo/go:1.11.1\n\nRUN apt update && apt install -y --no-i"
},
{
"path": ".github/CODEOWNERS",
"chars": 20,
"preview": "# general\n* @vcaesar"
},
{
"path": ".github/CONTRIBUTING.md",
"chars": 27,
"preview": "# Contributing to Robotgo\n\n"
},
{
"path": ".github/issue_template.md",
"chars": 957,
"preview": "1. Please **speak English (English only)**, this is the language everybody of us can speak and write.\n2. Please take a m"
},
{
"path": ".github/pull_request_template.md",
"chars": 945,
"preview": "The pull request will be closed without any reasons if it does not satisfy any of following requirements:\n\n1. Make sure "
},
{
"path": ".github/workflows/go.yml",
"chars": 645,
"preview": "name: Go\non: [push]\njobs:\n test:\n # name: build\n strategy:\n matrix:\n # go: [1.12.x, 1.13.x]\n o"
},
{
"path": ".gitignore",
"chars": 1477,
"preview": "# Object files\n.DS_Store\n.vscode\n.idea\n\nrobot_test.png\n# Examples\nexamples/screen/screen\nexamples/screen/saveCapture.png"
},
{
"path": ".travis.yml",
"chars": 1085,
"preview": "language: go\n\nos:\n - linux\n - osx\n\ngo:\n # - 1.7.x\n # - 1.8.x\n # - 1.9.x\n # - 1.10.x\n # - 1.11.x\n # - 1.12.x\n # "
},
{
"path": "CLA.md",
"chars": 5564,
"preview": "### AtomAI Individual Contributor License Agreement\n\nVersion: 2025-11-19 (https://cla-assistant.io/)\n\nThank you for your"
},
{
"path": "CONTRIBUTING.md",
"chars": 4364,
"preview": "# Contribution Guidelines\n\n## Introduction\n\nThis document explains how to contribute changes to the Robotgo project. It "
},
{
"path": "LICENSE",
"chars": 11357,
"preview": " Apache License\n Version 2.0, January 2004\n "
},
{
"path": "README.md",
"chars": 12571,
"preview": "# Robotgo\n\n<!-- <img align=\"right\" src=\"https://raw.githubusercontent.com/go-vgo/robotgo/master/logo.jpg\"> -->\n<!-- [.\n\n[\n\nfunc main() {\n\tout, err := io.ReadAll(os.S"
},
{
"path": "clipboard/cmd/gopaste/gopaste.go",
"chars": 174,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/go-vgo/robotgo/clipboard\"\n)\n\nfunc main() {\n\ttext, err := clipboard.ReadAll()"
},
{
"path": "clipboard/example/example.go",
"chars": 377,
"preview": "package main\n\nimport (\n\t\"log\"\n\n\t\"github.com/go-vgo/robotgo/clipboard\"\n)\n\nfunc main() {\n\terr := clipboard.WriteAll(\"日本語\")"
},
{
"path": "cv/README.md",
"chars": 14,
"preview": "robotgo gocv\n\n"
},
{
"path": "cv/gocv.go",
"chars": 11,
"preview": "package cv\n"
},
{
"path": "doc.go",
"chars": 3104,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n//\n// See the COPYRIGHT file at the top-level directory of this "
},
{
"path": "docs/CHANGELOG.md",
"chars": 22172,
"preview": "# CHANGELOG\n\n<!--### RobotGo-->\n## RobotGo v0.100.0, MT. Baker; Enhancement bitmap and image, add arm support...\n\n### Ad"
},
{
"path": "docs/README.md",
"chars": 110,
"preview": "# Docs\n\nDocuments are not necessarily updated synchronously, slower than godoc, please see examples and godoc."
},
{
"path": "docs/archive/README_zh.md",
"chars": 11046,
"preview": "# Robotgo\n\n# !!! Warning: this page not updated !!!\n\n[\n\n## [Keyboard](#Keyboard)\n\n##### [Keys](https://github.com/go-vgo/robotgo/bl"
},
{
"path": "docs/archive/doc_zh.md",
"chars": 12270,
"preview": "# 方法:\n\n##### [GetVersion](#GetVersion)\n\n## [键盘](#Keyboard)\n\n##### [Keys](https://github.com/go-vgo/robotgo/blob/master/d"
},
{
"path": "docs/install.md",
"chars": 793,
"preview": "## CrossCompiling\n\n##### Windows64 to windows32\n\n```Go\nSET CGO_ENABLED=1\nSET GOARCH=386\ngo build main.go\n```\n\n#### Other"
},
{
"path": "docs/keys.md",
"chars": 3188,
"preview": "## Type Conversion\n\n| | type conversion | func |\n| --- | ----------------------"
},
{
"path": "event/android/event_c.h",
"chars": 45,
"preview": "#include <linux/input.h>\n#include <string.h>\n"
},
{
"path": "event/ios/event_c.h",
"chars": 48,
"preview": "#include <AppKit/NSEvent.h>\n#include <string.h>\n"
},
{
"path": "examples/README.md",
"chars": 2921,
"preview": "# Robotgo examples\n\n## Install:\n```\ngo get -u github.com/go-vgo/robotgo \n```\n\n## [Examples:](https://github.com/go-vgo/"
},
{
"path": "examples/key/main.go",
"chars": 2906,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n//\n// See the COPYRIGHT file at the top-level directory of this "
},
{
"path": "examples/main.go",
"chars": 826,
"preview": "// Copyright (c) 2016-2025 AtomAI go-vgo, All rights reserved.\n//\n// See the COPYRIGHT file at the top-level directory o"
},
{
"path": "examples/mouse/main.go",
"chars": 2001,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n//\n// See the COPYRIGHT file at the top-level directory of this "
},
{
"path": "examples/scale/main.go",
"chars": 1287,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/go-vgo/robotgo\"\n)\n\nfunc main() {\n\t// syscall.NewLazyDLL(\"user32.dll\").NewPro"
},
{
"path": "examples/screen/main.go",
"chars": 2771,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n//\n// See the COPYRIGHT file at the top-level directory of this "
},
{
"path": "examples/window/main.go",
"chars": 3140,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n//\n// See the COPYRIGHT file at the top-level directory of this "
},
{
"path": "go.mod",
"chars": 1349,
"preview": "module github.com/go-vgo/robotgo\n\ngo 1.24.0\n\nrequire (\n\tgithub.com/otiai10/gosseract/v2 v2.4.1\n\t// github.com/robotn/goh"
},
{
"path": "go.sum",
"chars": 6478,
"preview": "github.com/BurntSushi/freetype-go v0.0.0-20160129220410-b763ddbfe298/go.mod h1:D+QujdIlUNfa0igpNMk6UIvlb6C252URs4yupRUV4"
},
{
"path": "img.go",
"chars": 4272,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n//\n// See the COPYRIGHT file at the top-level directory of this "
},
{
"path": "key/key.go",
"chars": 425,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n//\n// See the COPYRIGHT file at the top-level directory of this "
},
{
"path": "key/key_windows.go",
"chars": 50,
"preview": "//go:build windows\n// +build windows\n\npackage key\n"
},
{
"path": "key/keycode.h",
"chars": 9314,
"preview": "#pragma once\n#ifndef KEYCODE_H\n#define KEYCODE_H\n\n#include \"../base/os.h\"\n\n#if defined(IS_MACOSX)\n\n#include <Carbon/Carb"
},
{
"path": "key/keycode_c.h",
"chars": 3544,
"preview": "#include \"keycode.h\"\n\n#if defined(IS_MACOSX)\n\t#include <CoreFoundation/CoreFoundation.h>\n\t#include <Carbon/Carbon.h> /* "
},
{
"path": "key/keypress.h",
"chars": 997,
"preview": "#pragma once\n#ifndef KEYPRESS_H\n#define KEYPRESS_H\n\n#include <stdlib.h>\n#include \"../base/os.h\"\n#include \"../base/types."
},
{
"path": "key/keypress_c.h",
"chars": 9950,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n// \n// See the COPYRIGHT file at the top-level directory of this"
},
{
"path": "key.go",
"chars": 16705,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n//\n// See the COPYRIGHT file at the top-level directory of this "
},
{
"path": "keycode.go",
"chars": 918,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n//\n// See the COPYRIGHT file at the top-level directory of this "
},
{
"path": "mouse/mouse.go",
"chars": 427,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n//\n// See the COPYRIGHT file at the top-level directory of this "
},
{
"path": "mouse/mouse.h",
"chars": 945,
"preview": "#pragma once\n#ifndef MOUSE_H\n#define MOUSE_H\n\n#include \"../base/os.h\"\n#include \"../base/types.h\"\n#include <stdbool.h>\n\n#"
},
{
"path": "mouse/mouse_c.h",
"chars": 11382,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n//\n// See the COPYRIGHT file at the top-level directory of this "
},
{
"path": "mouse/mouse_darwin.go",
"chars": 50,
"preview": "//go:build darwin\n// +build darwin\n\npackage mouse\n"
},
{
"path": "mouse/mouse_windows.go",
"chars": 52,
"preview": "//go:build windows\n// +build windows\n\npackage mouse\n"
},
{
"path": "mouse/mouse_x11.go",
"chars": 73,
"preview": "//go:build !darwin && !windows\n// +build !darwin,!windows\n\npackage mouse\n"
},
{
"path": "ps.go",
"chars": 1682,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n//\n// See the COPYRIGHT file at the top-level directory of this "
},
{
"path": "robot_info_test.go",
"chars": 1282,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n//\n// See the COPYRIGHT file at the top-level directory of this "
},
{
"path": "robotgo.go",
"chars": 26562,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n//\n// See the COPYRIGHT file at the top-level directory of this "
},
{
"path": "robotgo_adb.go",
"chars": 16,
"preview": "package robotgo\n"
},
{
"path": "robotgo_android.go",
"chars": 16,
"preview": "package robotgo\n"
},
{
"path": "robotgo_fn_v1.go",
"chars": 2204,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n//\n// See the COPYRIGHT file at the top-level directory of this "
},
{
"path": "robotgo_mac.go",
"chars": 618,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n//\n// See the COPYRIGHT file at the top-level directory of this "
},
{
"path": "robotgo_mac_unix.go",
"chars": 614,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n//\n// See the COPYRIGHT file at the top-level directory of this "
},
{
"path": "robotgo_mac_win.go",
"chars": 1829,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n//\n// See the COPYRIGHT file at the top-level directory of this "
},
{
"path": "robotgo_ocr.go",
"chars": 853,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n//\n// See the COPYRIGHT file at the top-level directory of this "
},
{
"path": "robotgo_test.go",
"chars": 4065,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n//\n// See the COPYRIGHT file at the top-level directory of this "
},
{
"path": "robotgo_win.go",
"chars": 2634,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n//\n// See the COPYRIGHT file at the top-level directory of this "
},
{
"path": "robotgo_x11.go",
"chars": 5036,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n//\n// See the COPYRIGHT file at the top-level directory of this "
},
{
"path": "screen/goScreen.h",
"chars": 2925,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n// \n// See the COPYRIGHT file at the top-level directory of this"
},
{
"path": "screen/screen.go",
"chars": 15,
"preview": "package screen\n"
},
{
"path": "screen/screen_c.h",
"chars": 3696,
"preview": "//#include \"../base/os.h\"\n\n#if defined(IS_MACOSX)\n\t#include <ApplicationServices/ApplicationServices.h>\n#elif defined(US"
},
{
"path": "screen/screengrab_c.h",
"chars": 6045,
"preview": "#include \"../base/bitmap_free_c.h\"\n#include <stdlib.h> /* malloc() */\n\n#if defined(IS_MACOSX)\n\t#include <OpenGL/OpenGL.h"
},
{
"path": "screen.go",
"chars": 1492,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n//\n// See the COPYRIGHT file at the top-level directory of this "
},
{
"path": "test/index.html",
"chars": 840,
"preview": "<h1>Type and check the console</h1>\n\n<script>\n window.onclick = function(events) {\n console.log({\n "
},
{
"path": "wayland_n.go",
"chars": 37,
"preview": "// +bulid linux,next\npackage robotgo\n"
},
{
"path": "window/alert_c.h",
"chars": 1579,
"preview": "// #include \"os.h\"\n#if defined(IS_MACOSX)\n\t#include <CoreFoundation/CoreFoundation.h>\n#endif\n\n#if defined(IS_MACOSX)\n\tCF"
},
{
"path": "window/goWindow.h",
"chars": 1855,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n// \n// See the COPYRIGHT file at the top-level directory of this"
},
{
"path": "window/pub.h",
"chars": 8227,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n// \n// See the COPYRIGHT file at the top-level directory of this"
},
{
"path": "window/win_sys.h",
"chars": 4272,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n// \n// See the COPYRIGHT file at the top-level directory of this"
},
{
"path": "window/window.go",
"chars": 15,
"preview": "package window\n"
},
{
"path": "window/window.h",
"chars": 14827,
"preview": "// Copyright (c) 2016-2025 AtomAI, All rights reserved.\n// \n// See the COPYRIGHT file at the top-level directory of this"
},
{
"path": "windows_n.go",
"chars": 39,
"preview": "// +bulid windows,next\npackage robotgo\n"
}
]
About this extraction
This page contains the full source code of the go-vgo/robotgo GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 99 files (300.2 KB), approximately 95.1k tokens, and a symbol index with 598 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.