hotkey

package module
v0.0.0-...-3f1d359 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2023 License: MIT Imports: 2 Imported by: 21

README

hotkey Go Reference

About

This library provides HotKey for Go Language on Windows (including win32api wrapper, such as RegisterHotKey, UnregisterHotKey).

Get Started

$ go get github.com/MakeNowJust/hotkey

Import

import "github.com/MakeNowJust/hotkey"

Usage

The below is a minimal example.

package main

import (
	"fmt"

	"github.com/MakeNowJust/hotkey"
)

func main() {
	hkey := hotkey.New()

	quit := make(chan bool)

	hkey.Register(hotkey.Ctrl, 'Q', func() {
		fmt.Println("Quit")
		quit <- true
	})

	fmt.Println("Start hotkey's loop")
	fmt.Println("Push Ctrl-Q to escape and quit")
	<-quit
}

Let's see the example/ for more examples.

License

This software is released under the MIT License. http://opensource.org/licenses/mit-license.php

Copyright (c) 2014-2023 Hiroya Fujinami (a.k.a. TSUYUSATO "MakeNowJust" Kitsune)

Documentation

Overview

Package hotkey provides HotKey for Go Language.

Index

Constants

View Source
const (
	LBUTTON             = uint32(0x01)
	RBUTTON             = uint32(0x02)
	CANCEL              = uint32(0x03)
	MBUTTON             = uint32(0x04)
	XBUTTON1            = uint32(0x05)
	XBUTTON2            = uint32(0x06)
	BACK                = uint32(0x08)
	TAB                 = uint32(0x09)
	CLEAR               = uint32(0x0C)
	RETURN              = uint32(0x0D)
	SHIFT               = uint32(0x10)
	CONTROL             = uint32(0x11)
	MENU                = uint32(0x12)
	PAUSE               = uint32(0x13)
	CAPITAL             = uint32(0x14)
	KANA                = uint32(0x15)
	HANGUEL             = uint32(0x15)
	HANGUL              = uint32(0x15)
	JUNJA               = uint32(0x17)
	FINAL               = uint32(0x18)
	HANJA               = uint32(0x19)
	KANJI               = uint32(0x19)
	ESCAPE              = uint32(0x1B)
	CONVERT             = uint32(0x1C)
	NONCONVERT          = uint32(0x1D)
	ACCEPT              = uint32(0x1E)
	MODECHANGE          = uint32(0x1F)
	SPACE               = uint32(0x20)
	PRIOR               = uint32(0x21)
	NEXT                = uint32(0x22)
	END                 = uint32(0x23)
	HOME                = uint32(0x24)
	LEFT                = uint32(0x25)
	UP                  = uint32(0x26)
	RIGHT               = uint32(0x27)
	DOWN                = uint32(0x28)
	SELECT              = uint32(0x29)
	PRINT               = uint32(0x2A)
	EXECUTE             = uint32(0x2B)
	SNAPSHOT            = uint32(0x2C)
	INSERT              = uint32(0x2D)
	DELETE              = uint32(0x2E)
	HELP                = uint32(0x2F)
	LWIN                = uint32(0x5B)
	RWIN                = uint32(0x5C)
	APPS                = uint32(0x5D)
	SLEEP               = uint32(0x5F)
	NUMPAD0             = uint32(0x60)
	NUMPAD1             = uint32(0x61)
	NUMPAD2             = uint32(0x62)
	NUMPAD3             = uint32(0x63)
	NUMPAD4             = uint32(0x64)
	NUMPAD5             = uint32(0x65)
	NUMPAD6             = uint32(0x66)
	NUMPAD7             = uint32(0x67)
	NUMPAD8             = uint32(0x68)
	NUMPAD9             = uint32(0x69)
	MULTIPLY            = uint32(0x6A)
	ADD                 = uint32(0x6B)
	SEPARATOR           = uint32(0x6C)
	SUBTRACT            = uint32(0x6D)
	DECIMAL             = uint32(0x6E)
	DIVIDE              = uint32(0x6F)
	F1                  = uint32(0x70)
	F2                  = uint32(0x71)
	F3                  = uint32(0x72)
	F4                  = uint32(0x73)
	F5                  = uint32(0x74)
	F6                  = uint32(0x75)
	F7                  = uint32(0x76)
	F8                  = uint32(0x77)
	F9                  = uint32(0x78)
	F10                 = uint32(0x79)
	F11                 = uint32(0x7A)
	F12                 = uint32(0x7B)
	F13                 = uint32(0x7C)
	F14                 = uint32(0x7D)
	F15                 = uint32(0x7E)
	F16                 = uint32(0x7F)
	F17                 = uint32(0x80)
	F18                 = uint32(0x81)
	F19                 = uint32(0x82)
	F20                 = uint32(0x83)
	F21                 = uint32(0x84)
	F22                 = uint32(0x85)
	F23                 = uint32(0x86)
	F24                 = uint32(0x87)
	NUMLOCK             = uint32(0x90)
	SCROLL              = uint32(0x91)
	LSHIFT              = uint32(0xA0)
	RSHIFT              = uint32(0xA1)
	LCONTROL            = uint32(0xA2)
	RCONTROL            = uint32(0xA3)
	LMENU               = uint32(0xA4)
	RMENU               = uint32(0xA5)
	BROWSER_BACK        = uint32(0xA6)
	BROWSER_FORWARD     = uint32(0xA7)
	BROWSER_REFRESH     = uint32(0xA8)
	BROWSER_STOP        = uint32(0xA9)
	BROWSER_SEARCH      = uint32(0xAA)
	BROWSER_FAVORITES   = uint32(0xAB)
	BROWSER_HOME        = uint32(0xAC)
	VOLUME_MUTE         = uint32(0xAD)
	VOLUME_DOWN         = uint32(0xAE)
	VOLUME_UP           = uint32(0xAF)
	MEDIA_NEXT_TRACK    = uint32(0xB0)
	MEDIA_PREV_TRACK    = uint32(0xB1)
	MEDIA_STOP          = uint32(0xB2)
	MEDIA_PLAY_PAUSE    = uint32(0xB3)
	LAUNCH_MAIL         = uint32(0xB4)
	LAUNCH_MEDIA_SELECT = uint32(0xB5)
	LAUNCH_APP1         = uint32(0xB6)
	LAUNCH_APP2         = uint32(0xB7)
	OEM_1               = uint32(0xBA)
	OEM_PLUS            = uint32(0xBB)
	OEM_COMMA           = uint32(0xBC)
	OEM_MINUS           = uint32(0xBD)
	OEM_PERIOD          = uint32(0xBE)
	OEM_2               = uint32(0xBF)
	OEM_3               = uint32(0xC0)
	OEM_4               = uint32(0xDB)
	OEM_5               = uint32(0xDC)
	OEM_6               = uint32(0xDD)
	OEM_7               = uint32(0xDE)
	OEM_8               = uint32(0xDF)
	OEM_102             = uint32(0xE2)
	PROCESSKEY          = uint32(0xE5)
	PACKET              = uint32(0xE7)
	ATTN                = uint32(0xF6)
	CRSEL               = uint32(0xF7)
	EXSEL               = uint32(0xF8)
	EREOF               = uint32(0xF9)
	PLAY                = uint32(0xFA)
	ZOOM                = uint32(0xFB)
	NONAME              = uint32(0xFC)
	PA1                 = uint32(0xFD)
	OEM_CLEAR           = uint32(0xFE)
)

These are virtual key codes. See also, http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx

Variables

This section is empty.

Functions

This section is empty.

Types

type Id

type Id int32

A hotkey.Id is a identity number of registered hotkey.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

A hotkey's manager.

func New

func New() (man *Manager)

Create hotkey's manager and Start hotkey's loop. It is non-blocking.

func (*Manager) IsStop

func (man *Manager) IsStop() bool

Check if hotkey's loop is stopping.

func (*Manager) Register

func (man *Manager) Register(mods Modifier, vk uint32, handle func()) (id Id, err error)

Register a hotkey with modifiers and vk on man.

mods are hotkey's modifiers such as hotkey.Alt, hotkey.Ctrl+hotkey.Shift.

vk is a hotkey's virtual key code. See also http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx

func (*Manager) Stop

func (man *Manager) Stop()

Stop hotkey's loop.

func (*Manager) Unregister

func (man *Manager) Unregister(id Id)

Unregister a hotkey from id.

func (*Manager) UseDebugLog

func (man *Manager) UseDebugLog() *Manager

For debugging.

type Modifier

type Modifier uint32

A hotkey.Modifier specifies the keyboard modifier for hotkey.Register.

const (
	None  Modifier = hotkey_win.MOD_NONE
	Alt   Modifier = hotkey_win.MOD_ALT
	Ctrl  Modifier = hotkey_win.MOD_CONTROL
	Shift Modifier = hotkey_win.MOD_SHIFT
	Win   Modifier = hotkey_win.MOD_WIN
)

These are all members of hotkey.Modifier.

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL