Is it possible to send keystrokes and mouse clicks to the linux kernel
through a c-program ?

I know this is could be a security issue but what if the user was
root ?

I know it can sort of be done through x windows with xsendevent
library call but
some apps do not accept these events for security reasons.