Help us shape the future of Go! Take the 2026 Go Developer Survey

gkeybd

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

README

介绍

作者:京城郭少

利用本仓库,可以模拟键盘自动键入字符串

基于github.com/micmonay/keybd_event开发,万分感谢作者

注意事项

只支持英文

  • 使用前请切换到英文输入法。因为本程序只支持英文(模拟的是按键,而不是传递字符串)。

Demo

此示例程序将会模拟键盘输入"hello world!"

package main

import (
	"github.com/GuoFlight/gkeybd"
)

func main() {
	err := gkeybd.TypeStr("hello world!")
	if err != nil {
		panic(err)
	}
}

Demo2

如下示例可以将剪贴板内的内容粘贴出来

package main

import (
	"github.com/GuoFlight/gkeybd"
	"golang.design/x/clipboard"
)

func main() {
	err := clipboard.Init()
	if err != nil {
		panic(err)
	}
	content := string(clipboard.Read(clipboard.FmtText))
	err = gkeybd.TypeStr(content)
	if err != nil {
		panic(err)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var KbMap = map[string][]int{}/* 139 elements not displayed */
View Source
var KbShouldShift = map[string]bool{
	"~":  true,
	"!":  true,
	"@":  true,
	"#":  true,
	"$":  true,
	"%":  true,
	"^":  true,
	"&":  true,
	"*":  true,
	"(":  true,
	")":  true,
	"_":  true,
	"+":  true,
	"{":  true,
	"}":  true,
	"|":  true,
	":":  true,
	"\"": true,
	"<":  true,
	">":  true,
	"?":  true,
}

需要按下Shift才能输入的键

Functions

func TypeStr

func TypeStr(str string) error

按下字符串

Types

This section is empty.

Jump to

Keyboard shortcuts

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