Vienna to Prague part can be done cheaply in couple ways:
1) buy in advance on OEBB website Spar ticket (from 29 euro), but those not always available Spar tickets have limited availability
2) purchase EURegio ticket to Vienna-Znojmo (12 euro) or Vienna-Ceske Budejovice (22 euro), those tickets can be bought any time. Afterward just get Czech domestic ticket till Prague - 323 and 211 CZK respectively per person, but if there are two passengers you are eligible to receive group discount - 25%
3) Get Einfach-Raus-Ticket (28 euro for both of you) for you travels within the Austria until last Austrian station before Czech border - Gmund NO (take a look at Austrian rail network map on our "Austria" page), afterward once again domestic Czech ticket till Prague.
Prague-Krakow:
1) get CD eTicket Praha-Krakow - 19 euro (
https://eshop.cd.cz/international/info.aspx?lang=E)
2) get domestic ticket from Prague to Bohumin (445 CZK per person - 25% discount for the group) and buy Bohumin-Krakow-Bohumin return ticket (19.2 euro) - you will need return part of it on you way from Krakow to Vienna.
3) or simply purchase regular one way Praha-Krakow - it is not the expensive - 36.8 euro
Krakow-Vienna:
1) there are Spar tickets from Krakow to Vienna for as low as 29 euro, but you need to purchase them in advance (3 days) and only in Poland (not online) - guess it's not an option for you. But you can try asking for Spar ticket Krakow-Vienna in Vienna - OEBB might sell it.
2) use return part of your Krakow-Bohumin ticket + domestic Czech ticket Bohumin-Breclav (239 CZK)+ discounted Brno-Vienna 9 euro ticket (
https://eshop.cd.cz/international/info.aspx?lang=E)
3) regular fare Krakow-Vienna ticket - app. 60 euro (seems to much)
You might as well try switching the sequence of your travels - go to Krakow first (here you can purchase Spar ticket Vienna-Krakow for 29 euro), Krakow-Prague is not that expensive after all + Praha-Vienna only for 19 euro (
https://eshop.cd.cz/international/info.aspx?lang=E)