One of the very first actually useful programs I wrote was a simple macro program for UO. It would read a text file, parse the very basic commands in the file and then send them to the UO client by finding its HWND via FindWindow and calling SendMessage to send the key presses. I used this to macro easy skills like hiding with scripts like (I don't remember the exact command names now):
STARTLOOP
KEYPRESS F1 // client macro key for hiding skill
WAIT 1000
MOVERANDOM 4 // move 4 times in a random direction to get around server checks for using a skill in the same spot
WAIT 8000
ENDLOOP