Have you already decided where to pick up the rental car, or is this also flexible? Usually a large fee to pick up and drop off in different countries.
The direct train departs Ljubljana just before 9:00 and arrives to Budapest at 17:30. Pack a lunch with you. The direct train from Zagreb to Budapest is shorter and later, departing 16:30 to arrive 22:30.
Looking Up Train Schedules and Routes Online gives you the Deutsche Bahn train schedule link and tips for using it, all published through Dec. 14 and some later. For flights, try www.skyscanner.com, though there may not be much selection.