Unless the stars comes so close that they actually collide, two stars will not be able to catch each other gravitationally. The reason is energy conservation: As they approach each other, their potential energy is converted into kinetic energy, increasing their velocities. When they are closest, their velocities are at their highest, but since there's nothing to take out energy from the system, their kinetic energy will be converted back to potential energy, propelling them far apart again.
If a third star is present, however, this may be able to extract energy from the system, so that one star is slung out while the other two start orbiting each other.
Note however that the probability of two stars encountering each other extremely small, and that of three stars is close to zero.
In the above, I have ignored the presence of planets. In principle, a large planet could help, but since their masses are much smaller than the stars', their effect is quite small.