GO语言Robotgo学习-模拟按键事件(2)

KeyTap的使用,可以模拟热键

模拟热键WIN+R
  robotgo.KeyTap("r", "command")

WIN/CTRL/ENTER等功能键顺序从后到前的顺序

功能键对应的字符串

Github上的Robotgo作者的DOC文档

"backspace"
    "delete"        
    "enter"        
    "tab"
    "escape"
    "up"        Up arrow key           
    "down"      Down arrow key
    "right"     Right arrow key
    "left"      Left arrow key
    "home"
    "end"
    "pageup"
    "pagedown"
    "f1"
    "f2"
    "f3"
    "f4"
    "f5"
    "f6"
    "f7"
    "f8"
    "f9"
    "f10"
    "f11"
    "f12"
    "f13"
    "f14"
    "f15"
    "f16"
    "f17"
    "f18"
    "f19"
    "f20"
    "f21"
    "f22"
    "f23"
    "f24"
    "command"           Windows里面的WIN
    "alt"
    "control"
    "shift"
    "right_shift"
    "space"
    "printscreen"       No Mac support
    "insert"            No Mac support
    "menu"              Windows only

    "audio_mute"        Mute the volume
    "audio_vol_down"    Lower the volume
    "audio_vol_up"      Increase the volume
    "audio_play"
    "audio_stop"
    "audio_pause"       
    "audio_prev"        Previous Track
    "audio_next"        Next Track
    "audio_rewind"      Linux only
    "audio_forward"     Linux only
    "audio_repeat"      Linux only
    "audio_random"      Linux only

    "numpad_0"      No Linux support
    "numpad_1"      No Linux support
    "numpad_2"      No Linux support
    "numpad_3"      No Linux support
    "numpad_4"      No Linux support
    "numpad_5"      No Linux support
    "numpad_6"      No Linux support
    "numpad_7"      No Linux support
    "numpad_8"      No Linux support
    "numpad_9"      No Linux support

    "lights_mon_up"      Turn up monitor brightness                 No Windows support
    "lights_mon_down"    Turn down monitor brightness               No Windows support
    "lights_kbd_toggle"  Toggle keyboard backlight on/off           No Windows support
    "lights_kbd_up"      Turn up keyboard backlight brightness      No Windows support
    "lights_kbd_down"    Turn down keyboard backlight brightness    No Windows support

KeyToggle的使用,按下或抬起按键

.KeyToggle(按键,按下或抬起,按键,按键...)
.KeyToggle(按键,"down"/"up",按键,按键...)

robotgo.KeyToggle("alt","down")
robotgo.KeyToggle("alt","down","control")//长按ctrl+alt,如果打开了QQ,按下A可以截图

TypeStr的使用,在输入框中输入字符串

这个有缺陷,Hello真的打印出来可能是Helo,少字母
TypeStr(要打印的字符)

robotgo.TypeStr("Hello")

TypeStrDelay的使用,在输入框中输入字符串

TypeStrDelay(要打印的字符,每分钟输出的字符数)

robotgo.TypeStrDelay("Hello",500)

你可能感兴趣的:(GO语言Robotgo学习-模拟按键事件(2))