I am beginner level in programming(less than a year of experience). I am trying to use https://github.com/Sentdex/pygta5/blob/master/directkeys.py to imitate keyboard inputs in one of RPGs. I successfully managed to implement simple movements(WASD) but when I try to use game specific command as example "choose a closest enemy(Using TAB)" game doesn't react to the input. By doing some research I realized that the game most likely have internal driver level keyboard interaction which cannot be activated using Direct Inputs. I am asking for possible ways to solve the issue.
I tried to use virtual keys to try to imitate the keyboard inputs. Also, I tried to reassign one of the movement keys to "chose closest enemy button" but it produces no inputs as well. I am might start extensive research towards even lower-level keyboard interactions and see what I can do from there.
Here is small code sample
from directkeys import KeyPress, PressKey, ReleaseKey, W, ESC, C, TAB
import time
import win32gui
# open a window
handle = win32gui.FindWindow(0, "Game window")
win32gui.SetForegroundWindow(handle)
# Press and Release key
PressKey(W)
time.sleep(3)
ReleaseKey(W)
print("Script finished")