>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help User

# Controlling the Session Manager

A J program can use the Window Driver `wd` to access some aspects of the Session Manager, such as the Tools menu document windows. The names of Window Driver commands specific to the session manager start with the letters `sm`.

Tools Menu
You can add your own menu items to the Tools menu using `smsetcmd`. These also define the function keys. Your menu items can be accessed either by selecting the item directly from the Tools menu, or by pressing the corresponding function key. Function keys F2-F9 are available for this purpose.

The form is:

       wd 'smsetcmd num type name sentence;'

where:

- `num` corresponds to the function key being defined.

- `type` is one of :
  0 = remove definition
  1 = add definition, when invoked displays the sentence being run.
  2 = add definition, when invoked does not display the sentence being run.

- `name` is the text that appears on the Tools menu

- `sentence` is the sentence that will be run when the menu item is invoked.

  For example, the following will assign the sentence `load 'laserjet'` to the function key F2 and corresponding menu item LaserJet. The sentence will display when invoked:

         wd 'smsetcmd 2 1 "LaserJet" "load ''laserjet''";'

  When you next select the Tools menu, you will see the new menu item LaserJet. It is a good idea to define a "HotKey" letter and include the number of the corresponding function key in the menu item. If you do this, you can also right-justify the function key name by preceding it with a `TAB`. Thus, the above command could have been entered as:

         wd 'smsetcmd 2 1 "&LaserJet',TAB,'F2" "load ''laserjet''";'

  The menu item will now appear as:

         LaserJet F2

  To remove this definition, enter:

         wd 'smsetcmd 2 0;'

  Document Windows
  There are several Window Driver commands to access the document windows. In most cases, you must first select the window that is to be the target of subsequent commands (this need not be the active window). To select a window, you actually select its filename:

      qsmact
  | file name of selected window
      qsmall
  | file names of all windows
      qsmcsize
  | size of current execution window
      qsmout
  | file name of current execution window
      qsmsize
  | size of selected window (pixels)
      qsmwh
  | size of MDI client area (pixels)
      smappend
  | appends text to selected window
      smcascade
  | cascade windows
      smclose
  | close selected window
      smfocus
  | activates selected window
      smmove xywh
  | move and size selected window (pixels)
      smopen
  | opens selected filename, if not already open
      smread
  | reads data from selected window
      smsave
  | saves selected window (if modified)
      smscroll n
  | scrolls selected window
      smsetselect
  | set selected text
      smsel
  | selects window, by its filename
      smshow param
  | shows selected window, with parameters from the set:
      sw_hide              sw_maximize
      sw_minimize          sw_restore
      sw_show              sw_showmaximized
      sw_showminimized     sw_showminnoactive
      sw_showna            sw_shownoactivate
      sw_shownormal
      smssetcmd n t name sentence
  | modifies Tools menu
      smtile
  | tile windows down
      smtilea
  | tile windows across
      smwrite
  | writes text to selected window

  For example, the following will open file user\mywork.ijs for editing and make it the active window:

         wd 'smsel "user\mywork.ijs";smopen;smfocus'

  Having opened the window, you could write some text (e.g. in the noun `TXT`) to it as follows:

         wd 'smwrite *',TXT

>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help User