baykovr / AVPI

an open source voice command macro software
https://baykovr.github.io/gavpi.html
GNU General Public License v3.0
198 stars 42 forks source link

keypress output sequence mixed up #42

Closed 0verclock closed 8 years ago

0verclock commented 8 years ago

Hi, I try a simple keypres command to type "push". I create action sequence Keypress P, then keypress U, and so on. I test it using notepad, but the output type getting mixed up, like "phus" or "shup" or "hpus".

Is it just me or anybody else got the same problem? I am using Win7.

Thanks

baykovr commented 8 years ago

Without any wait commands its likely outputting too fast for notepad to handle.

Try adding a small wait in between the presses.

0verclock commented 8 years ago

Well, i did try that but i can only make it work with 100 delay. With 50 delay, the output still mixed up.

However, if i use mouse macro, i can output same sentence much faster to notepad. So i guess there is something other than just delay.

baykovr commented 8 years ago

How long are the sequences? I wonder if there is a similar issues with all sequences.

0verclock commented 8 years ago

Like i mention above, only 4 or 5 keypress. You really need to put a long delay between keypress to make it work, so its not practical for gaming.

I test with other voice command app, it can output the same sequence much faster with correct order to notepad.

baykovr commented 8 years ago

Thanks for the feedback, I'll try to get this resolved as best as I can.

0verclock commented 8 years ago

Have you been able to recreate the problem? Or it's only happening to me?

baykovr commented 8 years ago

So far not able to replicate issue.

0verclock commented 8 years ago

I have try it on different machine, this time I'm using my laptop. The problem still persist. Both machine (my PC n my laptop) is using Windows 7 64 bit home premium. I have put 10ms delay (see screenshot below)

gavpi action sequence

but as you can see the output sometimes got mixed up. gavpi mixed up output If i add the delay to 100ms, it will be always correct, but the typing will be too slow and not practical for gaming.

I am positive the problem is not with the notepad, because i can output longer text to notepad using autohotkey without problem. output to notepad using autohotkey

I hope this will help you recreate the problem.

baykovr commented 8 years ago

You are running it(gavpi) as administrator right? (just checking)

0verclock commented 8 years ago

Yes, my account is administrator and i have just try it using "running as administrator", and still same problem exist. Nobody ever have same problem with me so far?

AmethystAir commented 8 years ago

I'm seeing this same problem. When I sent a sequence of "abcdefg" without delays, here's the result of a few tests: gdfceba ecfgdba dfgceba dgcbfea fdgceba fdgceba gefdcba gfdceba edgcfba efcgdba

I'll look into this and see what I can find.

AmethystAir commented 8 years ago

Alright, this is another problem related to InputManager. InputManager starts a new thread for each "KeyPress" call, meaning it'll be completely out of order for multicore processors. KeyPress can take an array of keys to press, as well as a delay (how long to press each key for), so we'll need to rewrite how key presses are handled. It might be useful to have a "string" and "keypress" option; the "string" option could use the multithreaded KeyPress function to send an array of keys to press, and the current "keypress" option could be rewritten to use KeyDown and KeyUp with a "length of press" specified by the user. That should fix the race condition we're seeing here.

baykovr commented 8 years ago

Fixed by @AmethystAir in 3e2c7ae8d09fc1de1f5eca90cffd671dcc93220c

0verclock commented 8 years ago

glad somebody able to fix it! thanks AmethystAir! Now just waiting for the release.

baykovr commented 8 years ago

Cut release, @0verclock could you validate the fix for us? https://github.com/baykovr/AVPI/releases/tag/v0.10

0verclock commented 8 years ago

Yes, its working now. It send output keypress much-much faster and sequence is correct even without delay between each keypress. The output is fast enough, much faster than human could type, although not instantaneous. (I can see its output char by char).

Capability to output keypress & string would be perfect, so its easier to implement something like: Keypress T (teamchat button) + String("Hey I am using AVPI!"). +Keypress Enter.

Is it possible to output string as a whole? something like when you do "copy+paste" a sentence in notepad? It would enable much better "voice command typing" in games. :)

PS> i get unhandled expection with this release, when you start "listen" then try to close the apps. Need to launch task manager to close it.

baykovr commented 8 years ago

Thanks.

Looking into the crash this morning but cannot replicate so far. (As well as pasting.)

0verclock commented 8 years ago

image

image

This happened when you try to exit GAVPI from notification area icon when its listening. You need to load profile and issue some command first then exit.

Just forget about the pasting thing.. what i mean is, it still require some time to output a very long keypress sequence (i.e. 1 full sentence). If somehow its possible to output it very fast (like how you can paste a whole paragraph in notepad) it would be better. I know it might not be possible since this app simulate keyboard.