Documentation
¶
Index ¶
- Constants
- Variables
- func AddEvent(key string) bool
- func AddEvents(key string, arr ...string) bool
- func AddMouse(btn string, x ...int16) bool
- func AddMousePos(x, y int16) bool
- func End()
- func GetWindowsVKKeyCode(name string) (uint16, bool)
- func GetWindowsVKKeyName(code uint16) string
- func Process(evChan <-chan Event) (out chan bool)
- func Register(when Kind, cmds []string, cb func(Event)) error
- func SetLogLevel(level DebugLevel)
- func Start() chan Event
- func StopEvent()
- type Code
- type DebugLevel
- type Event
- type Kind
Constants ¶
const ( // Version get the gohook version Version = "v0.41.0" // HookEnabled honk enable status HookEnabled = 1 // iota HookDisabled = 2 KeyDown = 4 // 3 KeyHold = 3 // 4 KeyUp = 5 // 5 MouseDown = 7 // 6 MouseHold = 8 // 7 MouseUp = 6 // 8 MouseMove = 9 MouseDrag = 10 MouseWheel = 11 FakeEvent = 12 // Keychar could be v CharUndefined = 0xFFFF WheelUp = -1 WheelDown = 1 Debug = DebugLevel(13) Silent = DebugLevel(14) )
Variables ¶
var Keycode = WindowsVKCodes
var MouseMap = keycode.MouseMap
MouseMap defines the robotgo hook mouse's code map
var Special = keycode.Special
Special defines the special key map
var WindowsVKCodeToName = make(map[uint16]string)
Reverse mapping from VK code to key name
var WindowsVKCodes = map[string]uint16{}/* 112 elements not displayed */
Windows Virtual Key Codes (VK codes) - what your system actually sends Source: https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
Functions ¶
func AddEvent ¶
AddEvent add event listener,
parameters for the string type, the keyboard corresponding key parameters,
mouse arguments: mleft, center, mright, wheelDown, wheelUp, wheelLeft, wheelRight.
Use "hook.AddEvents()" or "gohook" add asynchronous event listener
func AddEvents ¶
AddEvents add global event hook
hook.AddEvents("q") hook.AddEvents("q", "ctrl") hook.AddEvents("q", "ctrl", "shift")
func AddMouse ¶
AddMouse add mouse event hook
mouse arguments: left, center, right, wheelDown, wheelUp, wheelLeft, wheelRight.
hook.AddMouse("left") hook.AddMouse("left", 100, 100)
func GetWindowsVKKeyCode ¶ added in v0.2.0
GetKeyCode returns the VK code for a given key name
func GetWindowsVKKeyName ¶ added in v0.2.0
GetKeyName returns the key name for a given VK code
func SetLogLevel ¶ added in v0.0.3
func SetLogLevel(level DebugLevel)
Types ¶
type DebugLevel ¶
type DebugLevel uint8
type Event ¶
type Event struct {
Kind Kind `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"`
Button uint16 `json:"button"`
Clicks uint16 `json:"clicks"`
X int16 `json:"x"`
Y int16 `json:"y"`
Amount uint16 `json:"amount"`
Rotation int32 `json:"rotation"`
Direction uint8 `json:"direction"`
}
Event Holds a system event
If it's a Keyboard event the relevant fields are: Mask, Keycode, Rawcode, and Keychar, Keychar is probably what you want.
If it's a Mouse event the relevant fields are: Button, Clicks, X, Y, Amount, Rotation and Direction