Hi,
Avast is blocking all emulated user input coming from an unsigned process when an Avast window is the foreground window (the window which is receiving user input). This change was required, because there was an attack reported to avast bug bounty program, which was using user input emulation API to deactivate protection completely. TeamViewer has signed executables, so there shouldn't be problem with TeamViewer unless you are using a warez (modified) version of TeamViewer. Also please use latest Avast 18.5 version as there were some bugs in previous releases related to this issue. I have tested latest UltraVNC 64bit and it contains signed executables too, but it is possible that afflicted computers have obsolete (unsigned) version of UltraVNC.
Thanks