Please
search the forums before posting, if you did that you'd surely have found this script I wrote a few years ago:
Matti's reply to Clear Screen?.
That script won't really clear the window, it'll simply quickly close and re-open it. This is because there's no way for scripts to access the chat history box, that's why this workaround was needed. Also, because it needs to re-open the window, the script will only work with one-to-one chats, group chats won't work.