As it has been mentioned it can't be 100% random as there is no such thing as completely random when talking about computers... however there can be so many variables that have to fit eachother that it seems random... and if as it has been suggested that one of these variables are the time in ms then it is virtually impossible to do a 100% safe enchant. Even if you do get a program to do it and try and calculate the right ms out of say 1000ms then there is still lag to be taken into consideration...
However if you are about to enchant an item then if you first go to a grocery store and buy oranges according to the number you want to OE (eg. OE -> 6, buy 6 oranges) and then run around your house while randomly throwing the oranges at whatever seems a suitable target (birds, parents, neighbours etc). When you're done throwing oranges you run to your computer very fast and do the enchant while licking your monitor it seems you have a higher chance of succeeding ::)