Too do autofire you can just use mouse_event to simulate pressing the fire key which is more than likely left mouse so you could do something like this:
Code:
if ( bAutoFire )
{
mouse_event( MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 );
mouse_event( MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 );
}