Hi andrzejz34802818,
This is certainly possible with the FDK or ExtendScript, although some overhead and experimentation will be required. So, I can't give you a comprehensive code sample, but perhaps I can get you started.
You can set FrameMaker to watch for keyboard events with:
F_ApiNotification(FA_Note_PostFunction, True);
Then, in the F_ApiNotify() callback, you should write whatever code you need to trigger the analysis. Basically, you'll need to decide which specific keyboard events that you want to monitor, then keep track of individual characters that were entered to form the strings of interest. Here is an example of capturing and reporting the last character entered:
VoidT F_ApiNotify(IntT notification,
F_ObjHandleT docId,
StringT sparm,
IntT iparm)
{
F_TextRangeT tr;
F_TextItemsT ti;
. . .
switch(notification)
{
case FA_Note_PostFunction:
if(iparm == TYPEIN)
{
tr = F_ApiGetTextRange(FV_SessionId, docId, FP_TextSelection);
tr.beg.offset--;
ti = F_ApiGetTextForRange(docId, &tr, FTI_String);
if(ti.len > 0)
F_ApiAlert(ti.val[0].u.sdata, FF_ALERT_CONTINUE_WARN);
F_ApiDeallocateTextItems(&ti);
}
. . .
To expand this into something useful to you, you would need to set up some kind of global string variable that appends each character as entered, meanwhile comparing it to whatever library of "similar segments" you have. Note that:
- TYPEIN may not be the only fcode iparm to look for... it is triggered by most keyboard actions, but not all. You'll have do some experimentation with the keystrokes that matter to you, cross-referencing with the different fcode constants declared in fcodes.h.
- This can be done in Extendscript too, maybe with less complexity. The general idea would be the same. My FDK sandbox happened to be more prepared for the sample code above than my Extendscript library.
I hope this helps some, at least to get you started. This will require lots of experimentation and will add overhead to your FM activities, but it seems well within reach.
Russ