

If you want to run Linux on a toaster with 16 MB flash, your best option is probably OpenWRT.
If you are running it on a regular PC, just turn off the monitor and plug out the speakers I guess. Recompiling Linux kernel looks too much like a hassle, you’ll need to disable specific device drivers to deactivate videocard and soundcard but keep the keyboard running.
Or boot into a recovery mode, the OS will disable everything except for the terminal, and you’ll need to enable networking using shell commands.
Your window needs to get the list of all other windows, find the one directly below it, and send a mouse click programmatically, using something like accessibility API.
Are you writing a keylogger?