I wrote a similar program a while ago to cheat at Word Soup which is another of the games on these machines.
http://chris-knott.appspot.com/projects/word_soup.html
They are technically not gambling. There are two different regulations in the UK - Amusements With Prizes, which are random and you need to be 18+ to play, and Skills With Prizes which are technically skill games and you don't need to be 18 to play, or have a gambling license to run.