Skip to content

How to disable system key & mouse's behavior, at the same time the hook event can be caught? #216

Open
@wilon

Description

@wilon
  • Robotgo version (or commit ref): latest
  • Go version: 1.12.1
  • Provide example code:
package main

import (
	"fmt"
	"time"

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

var eventsStorage []hook.Event

func main() {
	fmt.Println("Start...")

	// collect key events
	go keyListen()
	time.Sleep(time.Duration(10000) * time.Millisecond)

	// output regular
	for _, v := range eventsStorage {
		key := hook.RawcodetoKeychar(v.Rawcode)
		robotgo.KeyTap(key)
		time.Sleep(time.Duration(333) * time.Millisecond)
	}
}

func keyListen() {
	s := hook.Start()
	defer hook.End()
	for ev := range s {
		if ev.Rawcode >= 0 && ev.Kind == hook.KeyUp {
			eventsStorage = append(eventsStorage, ev)
		}
	}
}
  • run:

Run this file, then key press 'asdfg', wait and regular output 'asdfg'.
I want regular output 'asdfg' only, Key press behavior don't output.

Description

How to disable system key & mouse's behavior, at the same time the hook event can be caught?
I want to storage the event and then do something.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions