Donflamingo can control people using his strings. Why doesn't he use his ability to control Luffy, or Law instead of fighting them?
I think Doflamingo can only control those who are weaker than him with his strings.
The most powerful man he has been shown affecting with his strings by far is Jozu, but he didn't control him in the same way he did Bellamy, he just froze him still. Jozu couldn't move, but Doflamingo didn't move him around like a puppet either, whether because he couldn't or just didn't bother isn't clear.
I suspect that for people far weaker than Doffy, like Bellamy or Riku, he is able to completely control their movements, for those weaker than himself he is able to stop their movement, but not move them like a puppet, and that those stronger than him, like presumably Kaido, are able to move freely even when he's trying to control them.
Almost no-one in One Piece has any absolute powers, I don't think Doflamingo's puppet ability is magic, I think he is just able to exert a great deal of his strength through his strings. I think Luffy and Law are at the level that Doflamingo could perhaps stop their movements, but he wouldn't be able to puppet them around like Bellamy.
I think he has to make them weaker and break their mind psychologically before he can control them, like he does with Bellamy.
In my opinion, Doflamingo is only able to control opponents stronger or equally strong as him in a limited amount of time, while the latter still don't figure out yet what Doflamingo's power is about.
After they realize his strings Devil fruit power, they can use Haki to break free. However, their Haki must be strong enough to free themselves from Doflamingo's non-Haki strings, and stronger than Doflamingo's Haki in order to overcome his Haki-imbued strings.
Like when Luffy very recently did it with Gear fourth.
I hope I made sense in the comment above :)