For my addon I need a function that simulates just a single ESC button event from the keyboard, using Python. I've tried many things and this seems to be the only way left to abort
bpy.ops.render.render('INVOKE_DEFAULT')
operator without killing the whole Blender.
I've found this Ctypes method. This is builtin module unlike win32api or Pynput, so it can be imported without install right from inside the Blender. It seems to be exactly what I need. But importing the whole module and writing all those classes is obviously way too much for just a single ESC keyboard command, and unfortunately my current programming skills don't allow me to get through the whole module to find what I need. Please, can anyone help me with this?
--enable-event-simulate
which allows you to simulate events throughbpy.context.window.event_simulate("ESC", "PRESS")
. However this will only allow to create events through the operator, keyboard input will be ignored. $\endgroup$--enable-event-simulate
flag. You're right the second variant would only work if you want to stop rendering a sequence, it would not allow you to stop the current render. I don't think it's possible to directly terminate a modal operator through the API. $\endgroup$