9 Replies Latest reply on Dec 22, 2010 9:33 PM by FrancisFukuyama

    getchar() and putchar() in adobe javascript

    FrancisFukuyama

      One of the simplest programs that are written in C for newbies is pure input and output of characters from pressed keys in succession (with some max repetition allowed by the operating system settings for key pressed for extended period).

       

      #include <stdio.h>

      main(){

      int c;

      while ( (c=getchar()) != EOF)

           putchar(c);

      }

       

      I want to write a similar minimal program in acrobat javascript.

       

      The script may be document/application level ... most preferably not attached to any specific field on any page and listens for the Keystroke ... ie a pressed key.

       

      However, if it MUST be attached to a field ... then that field would be a button field which is on the current page and in focus ... but this will take away the simplicity I desire and as exhibited in the C program above which compiles and works.

       

      I want to print the letter corresponding to the key pressed on the console using this statement or another ...

       

      console.println(c);

       

      [QUESTION] How do I read the key pressed ?

       

      Thanks,

      Francis Fukuyama

        • 1. Re: getchar() and putchar() in adobe javascript
          FrancisFukuyama Level 1

          as a newbie i did lots of search in the sdk and guide before asking this question.

           

          i need acrobat to do events globally irrespective of page based on what key is pressed in certain contexts so it should not interfere with other normal operations.

           

          alternatively, i need three of four modifiers of mouse events but nothing is more convenient on the fingers than pressing a key like y/n for yes/no .

           

          Are there any non-reserved keys or non-reserved clicks events that can be recorded at the global, application or document level, or else be intercepted by a button and then recorded in some kind of file or hidden field for that button and then automatically "recorded or downloaded" into a text file as a data ?

           

          Thanks again for any help.

          Francis

          • 2. Re: getchar() and putchar() in adobe javascript
            George_Johnson MVP & Adobe Community Professional

            You would have to create a custom plug-in to have any hope of accomplishing this. JavaScript cannot do what you describe. You might want to pose this question in the Acrobat SDK forum here if you haven't already.

            1 person found this helpful
            • 3. Re: getchar() and putchar() in adobe javascript
              FrancisFukuyama Level 1

              Gentleman, I posed the question over there, however, you have not indicated what cannot be done. This is because, I have asked for alternative solutions for the accomplishment of my goal such as I have described ...

               

              such as mouse up or down or hover events that can be recognized by certain fields such as buttons.

               

              From one of the posts, I gather that the data can be stored using data objects.

               

              I am sure there have to be some solutions.

               

              Can you indicate how a plugin generally works ?

               

              Thanks

              Francis Fukuyama

              • 4. Re: getchar() and putchar() in adobe javascript
                dying veteran Level 1

                getchar() / putchar() are C functions and even deprecated in C++ or java where cin / cout are preferred.

                 

                [signature deleted by host]

                1 person found this helpful
                • 5. Re: getchar() and putchar() in adobe javascript
                  maxwyss Level 4

                  As it has been said, you will need a plug-in for catching arbitrary keypresses. However, there is an additional issue to keep in mind. Single key presses are already used in Acrobat (Reader), namely in the form of the single key accelerators (which are off by default, but may be turned on by your users). In such a case, you will encounter unpredictiable results.

                   

                  Acrobat JavaScript supports two modifier keys with mouse clicks. So, you have four distinct clicks available. In order to use them, you would place a transparent button field on top of the area where the user should click, and you would then evaluate the mouseUp event of that field. This is something you can do using JavaScript. Depending on what you intend to do, it will require some planning, but it is feasible.

                   

                  HTH.

                  • 6. Re: getchar() and putchar() in adobe javascript
                    FrancisFukuyama Level 1

                    I am the user ... I dont care about accelerator issues ... would be nice to learn how to write a plugin ... just some code in pure C that I can compile using gnu compiler like djgpp to try ................ a complete example would elicit much gratefulness.

                     

                    Acrobat JavaScript supports two modifier keys with mouse clicks. So, you  have four distinct clicks available. In order to use them, you would  place a transparent button field on top of the area where the user  should click, and you would then evaluate the mouseUp event of that  field. This is something you can do using JavaScript. Depending on what  you intend to do, it will require some planning, but it is feasible.

                     

                    please elaborate a little


                    a concrete and relevant minimal example with some illustrative extensions is worth thousand words of abstract theory and advice ...


                    gratefully,

                    Francis Fukuyama

                    • 7. Re: getchar() and putchar() in adobe javascript
                      FrancisFukuyama Level 1

                      @maxwyss

                       

                      I am awaiting your detailed suggestions and some example stanzas.

                       

                      I have explained my goal and i want to know how to go about

                      intercepting key presses etc. and when the mode is turned on, it

                      interprets 2 or 3 keys differently ... or the mouse clicks etc.

                       

                      Pleez suggest solution details.

                      • 8. Re: getchar() and putchar() in adobe javascript
                        gkaiseril MVP & Adobe Community Professional

                        Plugins are part of the Acrobat SCK forum.

                        • 9. Re: getchar() and putchar() in adobe javascript
                          FrancisFukuyama Level 1

                          --------> Plugins are part of the Acrobat SCK forum. <----------

                          Yeah ... if you visit the SDK forum, a post is there waiting for you
                          to offer help as a starter stanza ...

                           

                           

                          Adobe mail to forum system had clipped all the reply