I am trying to capture keystrokes sent to a MapleStory private server I created in order to train a neural network, but the below code does not detect any key strokes when the game window has focus. If any other window has focus, it works fine.
I already checked Applying low-level keyboard hooks with Python and SetWindowsHookExA but it has the same problem.
I was thinking of running the game client in a virtual machine and capture the keystrokes sent to that, but that is a less than optimal solution.
Does anyone know why I cannot detect key strokes in game, and know a way around it?
from pynput.keyboard import Key, Listener
def on_press(key):
print(str(key))
with Listener(on_press=on_press) as listener:
listener.join()