• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

FrameMaker: FDK or Extendscript how to capture keyboard input

New Here ,
Feb 14, 2018 Feb 14, 2018

Copy link to clipboard

Copied

I am writing an plugin for Framemaker that needs to capture text as it is entered by the user dynamically in order to check if any similar segments have already been entered using an author memory database. Is there any way that I can do this using the Framemaker FDK or Extendscript? Looking at the documentation there is no obvious way of doing this.

Thank you in advance

TOPICS
Scripting

Views

372

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Mentor , Feb 14, 2018 Feb 14, 2018

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

...

Votes

Translate

Translate
Mentor ,
Feb 14, 2018 Feb 14, 2018

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 15, 2018 Feb 15, 2018

Copy link to clipboard

Copied

Many thanks Russ,

I have also been able to replicate this using the ESTK. There are some interesting limitations on what you can do in the Notify() function, such as no access to local variables etc. and calling of local functions: you can only access and call globals.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 14, 2018 Feb 14, 2018

Copy link to clipboard

Copied

Start with page 217 of the FDK Programmer's Guide: "Responding to user-initiated events or FrameMaker product operations." Page 222, "Responding to text entry and actions that have no specific notifications," should have what you need. Page 225 has an example you can use to try it out. You should be able to modify the code so that it will work in ExtendScript.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 15, 2018 Feb 15, 2018

Copy link to clipboard

Copied

LATEST

Many thanks frameexpert,

This is very useful info.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines