Save command macros, and run them on a simple item use.
One command per line. Lines that are automatically wrapped still count as a single line, so long as you don't manually insert a newline character.
To execute, hold the book in your off-hand, and a stick in your main hand.