No they just read the memory. The whole point of an external cheat is to only read memory. They can still use Win32 to send inputs.
or the game engine could track internally what the player is looking at (GTA does this).
It's a bit slow, but you could grab the player ID, then check if the player is on your team or not and then fire. Either by sending a mouse input, or if I remember correctly by writing to a specific address.
However, with enough knowledge (which is mostly documented online) you could actually pull out the hitbox, skeleton and animation data and just run the line-box intersection step yourself. Easier to do internally by hooking in-game functions though.