What you're describing sounds very like a home-brewed version of the commercially-available "Mosquito Device." The site discusses the legality of the device in the UK in some detail.
Maybe check the frequency and volume that these folks use; if your box is no louder, it should be just as legal...