This might get you started. This just shows how to find that build window buffer and get some info from it.
_command void lines_of_build() name_info(',')
{
// See if the build window is an MDI window
int wid = _mdi.p_child._find_tile(".process");
if(!wid){
// Not MDI. Get the .process buffer window from
// the build toolwindow form, without activating it.
int formwid = _find_formobj('_tbshell_form','n');
if (formwid){
_nocheck _control _shellEditor;
wid = formwid._shellEditor;
}
}
if(wid){
message('Build window has 'wid.p_Noflines' line of text');
}
else{
message('Build window not found');
}
}