keybd_event
keybd_event copied to clipboard
Question/Bug - Setting the same key twice only outputs once
Issue / Question
Description
When trying to output a word like 'Hello' using the SetKeys
method, only one 'l' is outputted when using kb.Launching()
Is this intended?
Replicating
- OS = W10 Pro
- Go = go version go1.15.7 windows/amd64
Code:
package main
import (
"time"
"github.com/micmonay/keybd_event"
)
func main() {
kb, err := keybd_event.NewKeyBonding()
if err != nil {
panic(err)
}
time.Sleep(2 * time.Second)
// Select keys to be pressed
kb.SetKeys(keybd_event.VK_H, keybd_event.VK_E, keybd_event.VK_L, keybd_event.VK_L, keybd_event.VK_O, keybd_event.VK_L) // extra L at the end for test
// Press the selected keys
err = kb.Launching()
if err != nil {
panic(err)
}
}
Output
Sorry if this isn't a bug - If I am using this incorrectly, please could you give an example of how to use this correctly?
Hi
Sorry for the slow response. I have created this library at the base to simulate shortcut on my keyboard. I have written this library with this idea. In your example, you send press two same on the computer
You can write your code same of this example :
package main
import (
"time"
"github.com/micmonay/keybd_event"
)
func main() {
kb, err := keybd_event.NewKeyBonding()
if err != nil {
panic(err)
}
time.Sleep(2 * time.Second)
listKeys := []int{keybd_event.VK_H, keybd_event.VK_E, keybd_event.VK_L, keybd_event.VK_L, keybd_event.VK_O, keybd_event.VK_L}
// Select keys to be pressed
for _, key := range listKeys {
kb.SetKeys(key)
err = kb.Launching()
if err != nil {
panic(err)
}
}
}
Best regard