TCL Windows Help File

A windows help file of TCL and Tk is created by the htmlhelp target of the win\makefile.vc file.

Download Help file

APN provides a ready help file with additional extensions for download:

tcl-docs at sourceforge

ET This windows help file includes documentation for several packages plus tcl/tk docs as well. The included docs for the twapi package (the same author as this help file) is very valuable for scripting on windows when the target is a GUI program.

Below is a sample script used to integrate this help file via twapi from a text editor. The script is just an example, as it completely depends on my particular environment (such as my multiple monitors screen size and placement), and in particular the text editor I use.

My editor (the commercial product: EditPadpro) supports external scripting through a right click command to launch an arbitrary program and have it receive the currently selected text by reading stdin. Your editor will need to have something similar. In my case I launch a script (lookup.tcl) using a tclkit that has twapi built in.

     <pathto>mytclkit-with-twapi.exe <pathto>lookup.tcl

The script below does this: It launches the help file, reads stdin getting the selected text and then moves the help window to my second monitor (note the specific screen coordinates hard coded into the script) and resizes it for my tastes after which it sends the window keystrokes alt-d and the selected text thus filling in the search box on the index tab. It also moves the mouse pointer to the first entry in the index results. That is often what you want, so double clicking will show the page for your selection. For tcl/tk, usually there's several good choices, in particular the manual page for a tcl/tk command.

Note, in order to start the help program from a known state, I kill off any previously running process before launching it again with exec, which all told is quite fast on my system. Otherwise scripting a program on windows that is in an unknown state is somewhat tricky. The way I kill it off is somewhat dangerous, so be careful, as I use twapi to get a list of all the *.exe programs running, retrieve the command line and then match it against a string. The help program is hh.exe on windows.

package require twapi
catch {wm withdraw .} ;#don't want a tk window
set data [read stdin] ;#my editor puts the selected text here

# kill a running help to start fresh each time
foreach pid [twapi::get_process_ids -glob -path {*.exe}] { 
    set ans [twapi::get_process_info $pid -commandline]        
    if { [string match *hh.exe*WinHelp* $ans] } { ;#make sure it's us
        twapi::end_process $pid 
        break
    }
}

exec hh D:/stuff/TclWinHelp-2015-05-01.chm & ;#launch help afresh
after 800 ;# give it time to startup

set hand [twapi::find_windows -text "Tcl for Windows"] 
set hand [lindex $hand 0] ;# get 1st handle to help window
twapi::resize_window $hand 1800 1000 
twapi::move_window $hand 1920 10  ;# put it on monitor 2
twapi::move_mouse 1950 195 ;# place mouse over 1st result but don't click

set str "{ALT}n$data" ;#alt n activates index tab, keyword entry has focus
twapi::set_focus $hand ;# activate help window
after 200 ;# seems to work better with some delay
twapi::send_keys $str ;# send the keystokes to fill in the search key        

after 1200 exit

To find the appropriate mouse coordinates I use another little twapi script that opens a console window and writes the mouse coordinates of wherever the mouse is once every 2 seconds.

package require twapi
proc getmouse {} {
    set loc "unknown"
    if [catch {
        set loc [twapi::get_mouse_location]
    } err_code] {
        puts $err_code
    }
    puts $loc
    after 2000 getmouse
}
wm withdraw .
console show
getmouse