robotgo icon indicating copy to clipboard operation
robotgo copied to clipboard

robotgo crashes when typing 'ralt' key

Open AutoAwesome opened this issue 4 years ago • 8 comments

  • Robotgo version: (latest one you get with go get ...) v0.80.0
  • Go version: go version go1.13.10 linux/amd64
  • Gcc version: gcc version 9.2.0 (Gentoo 9.2.0-r2 p3)
  • Operating system and bit: Linux willow 5.5.5-gentoo x64
  • Can you reproduce the bug at Examples:
    • [ ] Yes (provide example code)
    • [ ] No
    • [x] Not relevant
  • Provide example code:
(base) imx@willow /tmp $ cat test.go 
package main

import "github.com/go-vgo/robotgo"

func main(){
        println("Up")
        robotgo.KeyToggle("ralt", "up")
}

(base) imx@willow /tmp $ go build test.go 
(base) imx@willow /tmp $ ./test 
Up
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  132 (XTEST)
  Minor opcode of failed request:  2 (X_XTestFakeInput)
  Value in failed request:  0x0
  Serial number of failed request:  14
  Current serial number in output stream:  15
  • Log gist:

Description

When trying to toggle ralt on a system with german keyboard layout, robotgo crashes with the stacktrace you can see above. Thanks!

Is there anything else I can provide to you to locate the culprit?

AutoAwesome avatar May 17 '20 19:05 AutoAwesome

I did a bit of research and found out that this implementation works fine https://github.com/micmonay/keybd_event/blob/master/keybd_linux.go

Maybe robotgo can borrow some code of it? :)

AutoAwesome avatar May 19 '20 01:05 AutoAwesome

I tested it on my Ubuntu, can't be reproduced; If the problem persists, please tell me how to reproduce it.

vcaesar avatar May 20 '20 15:05 vcaesar

Thanks for your reply and time!

Have you tried it with a german keyboard layout?

On german keyboard layouts you have to press ALTGR+Q to make an "@". The moment I try to press the ALTGR key (ralt in robogo) it crashes with the exception above.

But... maybe I am wrong and the ralt is not the AltGR key but simply a different Alt-Key which isn't on my keyboard?

AutoAwesome avatar May 20 '20 15:05 AutoAwesome

I think the issue is indeed that the ralt isn't the gralt key as I assumed.

I will try to add this to the list and see if it works.

[...]
K_GRALT = XK_ISO_Level3_Shift,
[...]

AutoAwesome avatar May 20 '20 16:05 AutoAwesome

I have tested it and it works! XK_ISO_Level3_Shift is what we need to be able to toggle/press/release.

If you want I can write a little patch for that.

Thanks for robotgo my friend. It's awesome :)

AutoAwesome avatar May 20 '20 16:05 AutoAwesome

Thks for your feedback, but there is no German keyboard.

vcaesar avatar May 27 '20 15:05 vcaesar

No problem my friend.

There are just 2 changes you have to do to support ISO_Level3-Shifting.

  1. To this file add K_GRALT = XK_ISO_Level3_Shift,
  2. To this file add { "gralt", K_GRALT },

This will work for linux machines.

I am not sure about MacOS.

Windows maps the ALTGR key to CTRL+ALT. So for windows there is no change needed.

AutoAwesome avatar May 28 '20 01:05 AutoAwesome

@AutoAwesome your fix worked! Anyway, it miss the configuration to use it like robotgo.KeyTap("q", "gralt"), can you help me to achieve that?? And in your opinion, to add letters like "òàèù", you have to add

K_O_GRAVE = XK_Ograve
{ "ò", K_O_GRAVE },

for every letters that I miss??

leonardospeca avatar Jun 03 '21 10:06 leonardospeca