calories > expenditure = weight gain (muscle/fat/water depending on diet)
calories < expenditure = weight loss
energy / diet pills = increase in caloric expenditure in theory due to increase metabolism or whatever means the energy/diet pill is utilizing
so still, if you eat a shit ton above maintenance and take diet pills, your going to gain weight. if you eat below maintenance your going to lose weight.
my question to you is if you want to gain muscle, why are you taking diet pills? that kind of sounds like conflicting goals to an extent. again there are a lot more variables and I would assume it is possible to a degree with AAS to alter your bf% down while gaining some lean mass...however just by the fact you are posing this question I would also assume you don't have the degree of knowledge to do so (no offense, I can't say I know that secret formula either).