Skip to content

Hotkey monitoring implementation #214

Open
@essenwbb

Description

@essenwbb

For the hotkey monitoring implementation I want to use goroutine+AddEvents/AddEvent

Example code:

package main

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

func main() {
	go addKeysListen("q", "ctrl")
	go addKeyListen("k")
	for {
		// do something
		time.Sleep(time.Millisecond * 50)
	}
}

func addKeysListen(key string, arr ...string) {
	for {
		if ok := robotgo.AddEvents(key, arr...); ok {
			fmt.Println("pressed Ctrl + q")
		}
	}
}

func addKeyListen(key string) {
	for {
		if ok := robotgo.AddEvent(key); ok {
			fmt.Println("Pressed k")
		}
	}
}

If I only listen to a hotkey, it is ok, but more than one will fail.
Can you change the underlying code to support this type of writing? Or has a more elegant solution?

github:clipboard recorder.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions