I wrote a little program one time to try to do this. I think I wrote it in Python or something. The idea was to have a list of "projected expenses" where each one would have things like the amount, the date of the next transaction, the frequency of the transaction, and so on. The program would then simulate time, determining when the next transaction would be, updating balances, and so on. You can actually do a very similar thing with a spreadsheet where you basically have a list of expenses that you manually paste in for each month in advance. Simply keep a running balance of each row, and make sure you don't forget any transactions that should be happening.
This works great for fixed expenses, or expenses that you know how much they are going to be for the next month. If you don't know, you can estimate, for instance you can make an educated guess at how much your electric bill will be the next month (if you haven't gotten the bill yet) and you can estimate how much you will spend on fuel based on reviewing previous months and some idea of whether your usage will differ in the next month. For variable expenses I would always err on the side of a larger amount than I expected to spend. It isn't going to be possible to budget to the exact penny unless you lead a very simple life, but the extra you allocate is important to cushion unexpected and unavoidable overruns.
Once you have this done for expenses against your bank account, you can see what your "low water mark" is for the month, or whatever time period you project out to. If this is above your minimum, then you can see how much you can safely allocate to, e.g. paying off debt. Throwing a credit card into the mix can make things a bit more predictable in the current month, especially for unpredictable amounts, but it is a bit more complicated as now you have a second account that you have to track that has to get deducted from your first account when it becomes due in the following month. I am assuming a typical card where you have something like a 25 day grace period to pay without interest along with up to 30 days after the expense before the grace period starts, depending on the relationship between your cut-off date and when the actual expense occurs.