Hello guys.
I've learned lots of things in here over several years and thanks to you all and this beautiful community.
I'm stuggling with keyrepeat these days, (actually years) and still finding the best solution.
My game requires lots of key repeats and keep pressing keys.
For example, normal users are usually pressing at least 1 key during play time and key stroke in the game should be like
[(fire) - some delay - (fire) - (nodelay fire) - continuously fire until key released].
Fire speed and the delay between a first fire and a second fire are set by windows setting (which means registry directly or in the control panel).
My problem is when I use key down command (don't release key for keep pressing) via Send comamnd (or send input), Fire only executed one time and doesn't keep firing.
When my script was simple and not that long, I made my script to repeat send command press and release continuously.
However my script is quite complex and require lots of math during key press so because of hard-loaded math, fire can't continue and stop during math.
I figured out some solutions and checked it's working, but because of its uneffectiveness and ugly code, I wonder someone help me for the better solution.
Solution1. Run 2 Threads.
Original script create ini file and keep update for the second script, and second script handle the all keystrokes.
second script only cares about keystroke, so read ini file about expected status of current keystate and make some changes about it.
Soulution2. Using Arduino
It's actually same with solution1. I have an Arduino leonardo and use it as programmable keyboard, which does exactly same as second script's role in Solution 1.
Pros is low memory and Cons is need Arduino device.
Without running 2 threads or 3rd device, is there any way to make key repeatedly fire with only one send key down command?
have a nice day
KeyPress and KeyRepeat
Re: KeyPress and KeyRepeat
If you use Loop, you can send as many times as you want.