robotgo icon indicating copy to clipboard operation
robotgo copied to clipboard

Override keyboard input

Open noah427 opened this issue 3 years ago • 2 comments

  • Robotgo version (or commit ref): v0.100.10
  • Go version: 1.17.5
  • Gcc version: 11.1.0
  • Operating system and bit: Linux x64
  • Resolution: 1680x1050
  • Can you reproduce the bug at Examples:
    • [ ] Yes (provide example code)
    • [ ] No
    • [+] Not relevant

Is it possible to override keyboard input so that the original input is cancelled? For example : I have an EventHook that captures a press of the "w" key and then taps the "q" key. I would like to prevent the original input from being applied. Normally if you were to type w with that code running you would see "wq" appear but I am looking for a way to stop the original input from going through.

noah427 avatar Dec 31 '21 09:12 noah427

Relevant suggestion. At the moment I am only thinking of using SetWindowsHookExA and WH_KEYBOARD_LL callback manually

alchem1ster avatar Nov 25 '22 15:11 alchem1ster

now this repo dont support this, but the underwood lib uiohook support prevent event propagation by set event.reserved = 1

this need to refactor the wrap of uiohook, now code use chan string to pass event from go side to c code, so event if you set the event.Reserved = 1 , it has no effect, need a pr to fix this. and the uiohook lib original support this feature in windows and
macos , not support x11, maybe it will support x11 and wayland in 1.3 by evdev. you can read the two link for more details

https://github.com/go-vgo/robotgo/issues/525

https://github.com/robotn/gohook/issues/16 prevent father propogation

type Event struct {
	Kind     uint8 `json:"id"`
	When     time.Time
	Mask     uint16 `json:"mask"`
	Reserved uint16 `json:"reserved"`

	Keycode uint16 `json:"keycode"`
	Rawcode uint16 `json:"rawcode"`
	Keychar rune   `json:"keychar"`
}

soluty avatar Jan 28 '23 16:01 soluty