What would happen and how could have they done it?
If the Ottomans win...
It has to happen during the Siege of Vienna
The Habsburg are crushed. This means their Hungarian possesion be come a part of Imre Thököly. Ottomans might get Habsburg Croatia. And Vienna has a Hungarian garrison to defend. Vienna might fall later to the Germans but at that time the Austrian threat is as good as gone.
There is no invasion of Germany or even Italy let alone Western Europe. Mehmed IV remains on the throne until 1693. He and his succesors can reform and keep up the modernisation.
Anything after, cannot turned into a win with all the interventions. Only a statlemate. The battles of Mohacs (1687) and Slankamen (1691) could have prevented the loss of Hungary. But thats it.