I'm making a custom gaming ai for preexisting games and need to have it run in the background, be able to put screen-captures into variables/arrays/etc., and control the mouse and keyboard on my Ubuntu Linux. I've searched extensively but can't find anything on how to do this. I'm not sure how complicated what I'm asking for is, so if functions or code snippets are unavailable I'll take a link to somewhere that will show me how to write it.