The Ben Ish Chai writes that the book to which the verse refers is the Torah, which the Talmud (Chullin 139b) says alluded to the Purim story early on (Bireishis 3:11).
Similarly, the author of Yismach Moshe explains that everything went according to the book, the Torah. In other words, the Torah’s (Devorim 19:19) punishment for false witnesses (with some exceptions) is to the court to administer the punishment the false witnesses attempted to bring upon their intended victim. Just so, Haman’s hanging was just what he intended on Mordechai, his victim.
On a different note, the Vilna Gaon uses this phrase to demonstrate the importance of praying with a written text. One who speaks before the King of kings should do so with a book to avoid any inappropriate thoughts.