Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question/Bug - Setting the same key twice only outputs once #30

Open
odgers-chrisf opened this issue Jan 29, 2021 · 2 comments
Open

Question/Bug - Setting the same key twice only outputs once #30

odgers-chrisf opened this issue Jan 29, 2021 · 2 comments

Comments

@odgers-chrisf
Copy link

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

image

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?

@micmonay
Copy link
Owner

micmonay commented Mar 2, 2021

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

@uiosun
Copy link

uiosun commented Oct 5, 2024

Add more information to the bug:

When you input string has repeat character, like: "Hello" / "000263" etc.

foreach character is bad work, has some rate hit the bug, waiting 20~30 millisecond is good choice in my PC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants