The "Xop" package provides Tcl/Tk with access to various low-level X window system functions. Its capabilities include:
These facilities are provided via the "xop" tcl command. The intended purpose of the Xop package is to provide certain low-level X11 facilities required by window managers, but the package need not be used in that way.
http://www.eecs.umich.edu/~mckay/computer/xop0.3.tar.gz