Although the title is related to modding, I see that your example is an Aimbot. Cheating and modding are, to a certain extent, different.
As a rule of thumb (although not exclusively) cheating is done via memory manipulation or DLL injection (as
Sheogorath and
RBA mentioned) and it involves mostly knowledge of addressing spaces, memory addressing in general, how DLL's work, how you can inject one, how can you bypass anti-cheating efforts (and implicitly how do anti-cheat such as PunkBuster, VAC (Steam/Valve) and Fairfight (Origin/EA) work).
Modding is usually done via APIs or tools that have been directly exposed by the developer of the original game. This is also not exclusive, as many mods for many games have been done through reverse engineering and techniques usually used for cheating.
If I were to give a suggestion, I would reinforce
Sheogorath's suggestion to download, install and do the tutorials of Cheat Engine (
http://www.cheatengine.org/) if your goal is to develop cheats or trainers. Whilst doing this deepen your knowledge of the topics that you are not familiar with that are presented in the aforementioned tutorials. Once you've done that you can go onto trying to build a custom Cheat Engine script (LUA) for a more modern game (2013+) to see how the lessons apply in a "real-world" scenario.
If modding is your thing, unfortunately I have no good advice as I've never done/worked on/read about how a mod is built. Although, intuition-wise, object oriented programming, C++, C#/Java spring to mind as relevant topics.
L.E.: If creating cheats & co. is indeed your goal, a nice place to start from is studying how DLL injection works (it's a technique used very, very often) when injecting into the affected process's mem space, then read on how DLL injection works when you inject into a different process other than your target (i.e. inject into Skype to cheat in Counter Strike with the goal of avoiding detection). Afterwards I for one would try to build my own DLL injector and use it to see how the technique works. Finally, a study on WINAPI hooking and building a working function hook will definitely be of use.