The original VNC had a scripting add-on. It doesn't look like it has made it into UltraVNC though. Don't know about other flavours.