I'm trying to create autonomous truck in Euro Truck Simulator 2, using PIL for image capture, OpenCV for image processing and tensorflow for action prediction.
The only problem is I am not able to send input to Euro Truck Simulator 2 game.
I am using Windows 10, capturing in 1280x720 windowed mode. Using Win32 Direct Input API as described below
Stackoverflow Answer implementation of Direct Input in Python
I am using PressKey function for W (0x11 Code) key and sleeping execution for 5 secs and then ReleaseKey to release the key.
The truck just won't move, the window is in focus while the script is running and also I can manually drive the truck as usual
PressKey(0x11)
time.sleep(5)
ReleaseKey(0x11)
time.sleep(1)
Note: I have also tried using pyautogui. Looping 50 times and pressing the key each time