Slow press even with _pause = False
Hi! First of all, thanks for working to make this library happen!
I'm currently implementing a bot that uses a NN to predict which key should be pressed and then I input it with the press() function. My problem is that when I'm not doing any input I can get about 60-70 fps (measured withing the mss loop for screen recording) but when using press() it drops down to about 3 fps and 4 fps if I use _pause=False.
I tryed using only the functions:
def PressKey(hexKeyCode):
extra = ctypes.c_ulong(0)
ii_ = Input_I()
ii_.ki = KeyBdInput( 0, hexKeyCode, 0x0008, 0, ctypes.pointer(extra) )
x = Input( ctypes.c_ulong(1), ii_ )
ctypes.windll.user32.SendInput(1, ctypes.pointer(x), ctypes.sizeof(x))
def ReleaseKey(hexKeyCode):
extra = ctypes.c_ulong(0)
ii_ = Input_I()
ii_.ki = KeyBdInput( 0, hexKeyCode, 0x0008 | 0x0002, 0, ctypes.pointer(extra) )
x = Input( ctypes.c_ulong(1), ii_ )
ctypes.windll.user32.SendInput(1, ctypes.pointer(x), ctypes.sizeof(x))
And I recover the 60 fps but it does miss some inputs randomly.
Are there any other ways of making pydirectinput faster?
Thanks a lot in advance!
Just FYI in case you didn't figure this out, you have to set pydirectinput.PAUSE to False before you call typewrite. As far as I can tell the _pause argument doesn't do anything. I can't see it being used anywhere in the functions it exists in; this is usually denoted by the leading underscore.
doing pydirectinput.PAUSE = 0.0 fixed the issue for me.