It seems to me that the dependence on sampfuncs is unnecessary for this script, since it only checks that the chat is closed upon activation.
I removed this check, the script still works, but keep in mind that it will also trigger on capslock, when chat is open.
You may want to change the...