mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-31 06:13:55 +00:00
Merge pull request #471 from go-vgo/bitmap-pr
Optimize key toggle code and Update README.md
This commit is contained in:
commit
3e97de3745
@ -1,5 +1,5 @@
|
||||
# FROM golang:1.10.1
|
||||
FROM golang:1.17.6-stretch AS build
|
||||
FROM golang:1.17.7-stretch AS build
|
||||
# FROM govgo/go:1.11.1
|
||||
|
||||
RUN apt update && apt install -y --no-install-recommends \
|
||||
|
@ -270,7 +270,7 @@ func main() {
|
||||
}
|
||||
```
|
||||
|
||||
#### [Bitmap](https://github.com/vcaesar/bitmap/blob/master/examples/main.go)
|
||||
#### [Bitmap](https://github.com/vcaesar/bitmap/blob/main/examples/main.go)
|
||||
|
||||
```Go
|
||||
package main
|
||||
|
@ -34,7 +34,7 @@ environment:
|
||||
PATH: C:\msys64\mingw32\bin\;C:\Program Files (x86)\NSIS\;%PATH%
|
||||
# - COMPILER: MINGW_W64
|
||||
# ARCHITECTURE: x64
|
||||
GOVERSION: 1.17.6
|
||||
GOVERSION: 1.17.7
|
||||
# GOPATH: c:\gopath
|
||||
|
||||
# scripts that run after cloning repository
|
||||
|
2
key.go
2
key.go
@ -384,7 +384,7 @@ func keyToggles(k string, keyArr []string) error {
|
||||
down = false
|
||||
}
|
||||
|
||||
flags := getFlagsFromValue(keyArr)
|
||||
flags := getFlagsFromValue(keyArr[1:])
|
||||
key, err := checkKeyCodes(k)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -140,8 +140,9 @@ void toggleKeyCode(MMKeyCode code, const bool down, MMKeyFlags flags) {
|
||||
assert(keyEvent != NULL);
|
||||
|
||||
CGEventSetType(keyEvent, down ? kCGEventKeyDown : kCGEventKeyUp);
|
||||
// CGEventSetFlags(keyEvent, flags);
|
||||
CGEventSetFlags(keyEvent, (int) flags);
|
||||
if (flags != 0) {
|
||||
CGEventSetFlags(keyEvent, (CGEventFlags) flags);
|
||||
}
|
||||
CGEventPost(kCGSessionEventTap, keyEvent);
|
||||
CFRelease(keyEvent);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user