Update: I did some more research about an possible UDF-solution.
Preferably I would do something like this:
#include "udf.h"
#include "dpm.h"
#include "cx.h"

CX_Interpret_String((format #f "file/export/particle-history-data cfdpost tracktest injection-0 , acc-total-mag force-coll-mag force-total-mag , ,"))
I am able to compile this UDF but it seems like it cannot access the environment. When I start the simulation the error "unbound Variable" is printed in the console.
I have found some old forum discussions (2006/2013) on the topic "use tui-commands via UDF" stating that back then, no way was known to call a tui-command by an UDF.
Even though I wonder if this is possible now, since quite a bit time has passed since then?
Or, like written in my first post, if there is any other possible way?